The code that caused this issue is
https://github.com/clojure/clojure/commit/a1c3dafec01ab02fb10d91f98b9ffd3241e860c0?diff=unified#diff-03234b041c0917ec98f2ad9477a0a014R260
But this is not a bug in the clojure code nor a regression, in fact
you can reproduce this in any clojure version with the following code:

(defmacro m [] `[~@(keys &env)])
(defprotocol p (f [_]))
(deftype t [^int x] p (f [_] (m)))


This is happening for the same reason why (let [x (int 1)] (identity
^int x)) throws the same error, the fix in your case is to use (map
#(with-meta % {}) (keys &env))

On Tue, Jan 2, 2018 at 11:03 PM, Luc <lprefonta...@softaddicts.ca> wrote:
> Hi,
>
> finally got some time to dig deeper. The minimal code to reproduce this has
> shrunk:
>
> (defprotocol Anonymous
>   (start-job! [this]))
>
> (defrecord NoopJob []
>   Anonymous
>   (start-job! [this]
>     (yabug.services.logger/environment)))
>
> The environment macro was called by log/error but not by the other severity
> level macros.
> The error macro within a defrecord is the only case where it fails.
>
> This is the environment macro definition:
>
> (defmacro environment
>   "Expands to code that generates a map of locals: names to values"
>   []
>   (clojure.pprint/pprint (macroexpand `(zipmap '~(keys &env) [~@(keys
> &env)])))
>   `(zipmap '~(keys &env) [~@(keys &env)]))
>
> I added the macroexpand in the macro to get what it expands to in the
> context of the defrecord
> at compile time.
> Outside of the defrecord the compiler does not complain (let, ...)). The
> protocol by itself does not seem
> to be a significant factor. I got this at different places under different
> protocols.
>
> This is the 1.9 macro expansion outputted at compile time before ending up
> with exception while evaluating
> the resulting code:
>
> (clojure.core/zipmap
>  '(__hash __meta this __hasheq __extmap)
>  [__hash __meta this __hasheq __extmap])
>
> This is the 1.8 macroexpansion of this macro which is a bit shorter, there's
> seem to be less context generated by the defrecord macro
> expansion:
>
> (clojure.core/zipmap '(__meta this __extmap) [__meta this __extmap])
>
> The expansion of the defrecord context is slightly bigger but nothing hits
> me when I compare both expanded vectors at the end.
> I am assuming that this the expression that the compiler cannot evaluate in
> 1.9 since it the error originates from the VectorExpr
> class.
> Is there anything obvious on with the evaluation of the last vector in the
> 1.9 expansion that would explain this error ?
> I don't see it.
>
> Just to make things more puzzling the expansion literally works in the 1.9
> REPL:
>
> => (defrecord NoopJob []
>      impl/GatewayJob
>      (start-job! [this]
>        (clojure.core/zipmap
>          '(__hash __meta this __hasheq __extmap)
>          [__hash __meta this __hasheq __extmap])))
> yabug.jobs.noop.NoopJob
>
> Grr...
>
> Will sleep on it and toy with it tomorrow by expanding a bit the test cases.
> It's nearly 22:00 Morocco time here.
> I need a break and some sleep.
>
> Luc P.
>
> On Saturday, 30 December 2017 01:00:05 UTC, Alex Miller wrote:
>>
>> On Fri, Dec 29, 2017 at 6:17 PM, Luc <lprefo...@softaddicts.ca> wrote:
>>
>>>
>>> here it is, I did not get through the compiler source code yet, it might
>>> be obvious to you:
>>>
>>> java.lang.UnsupportedOperationException: Can't type hint a primitive
>>> local, compiling:(yabug/jobs/noop.clj:21:9)
>>> Exception in thread "main" java.lang.UnsupportedOperationException: Can't
>>> type hint a primitive local, compiling:(yabug/jobs/noop.clj:21:9)
>>
>>
>> What's the code here? ^^
>>
>>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to