def in a letfn function emits unwanted warning

Description

File src/my/app.cljs :


Compiler output : WARNING: b at line 2 is being replaced at line 2 src/my/app.cljs

Environment

None

Activity

Show:
Elton Law
December 11, 2019, 7:35 AM

In the parse multimethod for letfn*, there is an initial pass and
then a second pass. analyze is called twice on the passed in form and
when the form contains a 'def the associated parse multimethod will
run twice:

...so that env/*compiler* already has sym during the second pass.
That's one of the 5 conditions for sending out the warning for
:redef-in-file.

(not *allowing-redef*) is another one of those conditions and this
change adding (allowing-redef ...) to just the second analyze pass
sets it to true temporarily so that this error message will not send
when a def is in a letfn.

There are no tests for this because, this only happens when compiling a
file because two of the other preconditions to send the warning are
*file-defs* and (get @*file-defs* sym) and *file-defs* only gets
initlaized in cljs.compiler/compile-file

 

Roman Liutikov
September 16, 2019, 8:50 AM

Can repro on current master.

Assignee

Elton Law

Reporter

leonoel

Labels

None

Approval

None

Patch

Code

Priority

Minor