JuliaLang / julia

The Julia Programming Language

Home Page:https://julialang.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Local scope name mangling not occuring in generated function bodies

MasonProtter opened this issue · comments

MWE:

julia> let
           @generated fib3(x) = :(x < 2 ? x : fib3(x-1) + fib3(x-2))
           fib3(3)
       end
ERROR: UndefVarError: fib3 not defined
Stacktrace:
 [1] macro expansion at ./REPL[26]:2 [inlined]
 [2] (::var"#fib3#54")(::Int64) at ./REPL[26]:2
 [3] top-level scope at REPL[26]:3

If this were a regular function, all references to fib3 would get replaced with gensyms but this is not happening in the quote block to the generated function.

Looks like still reproducible as of 1.8.3 and 1.9.0-alpha1, not sure what best labels for this are though

I guess “lowering” and “bug”? Also not sure.