reify inside defn creates nil var tagged as function type

Description

If you use reify inside of defn an anonymous Var will be introduced which is tagged as being of function type, when in fact it has a value of nil instead of a function value.

This repro illustrates that the compiler thinks the Var holds a function (by passing it to a numeric function simply to get the compiler to indicate the type in the diagnostic):

1 2 3 4 5 6 7 8 9 10 ClojureScript 1.10.520 cljs.user=> (defn x [] (reify Object (foo [_]))) #'cljs.user/x cljs.user=> (ns-publics 'cljs.user) {x #'cljs.user/x, t_cljs$user621 #'cljs.user/t_cljs$user621, ->t_cljs$user621 #'cljs.user/->t_cljs$user621} cljs.user=> t_cljs$user621 nil cljs.user=> (+ t_cljs$user621 1) WARNING: cljs.core/+, all arguments must be numbers, got [function number] instead at line 1 <cljs repl> ##NaN

Also see CLJS-3159.

This can be important if the compiler makes optimizations based on this incorrect type information. See, for example, the issue surrounding ns-publics in CLJS-2875.

Environment

None

Status

Assignee

Unassigned

Reporter

Mike Fikes

Labels

None

Approval

None

Patch

None

Priority

Minor