Destructuring with & fails with defn in self-hosted eval

Description

Prints {:ns test.ns, :value nil}

:value should be the function instead of nil

(Destructuring with & works in fn or let forms)

Environment

Windows Chrome (71.0.3578.98 - latest)

Activity

Show:
Mike Fikes
January 6, 2019, 3:31 PM

Hey Richard. This is actually not specific to self-hosted: Not all def forms return their inits, and this is the case for a variadic fn definition.

You can see this if you, say write some code that looks like

and then attempt to use x (you will see that it is nil when you compile the code for actual use outside of a REPL).

You can also see this readily at a conventional REPL if you disable :def-emits-var (https://clojurescript.org/reference/repl-options#def-emits-var)

Note that, in the above the defn form returns nil, but still has a side effect in the current namespace.

Alternatively, in the self-hosted example you gave, if you enable :def-emits-var you will get the var back:

Mike Fikes
March 20, 2019, 12:45 PM

Closing as not an issue.

Assignee

Unassigned

Reporter

import

Labels

Approval

None

Patch

None

Affects versions

Priority

Major
Configure