Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

locals doesn't respect macro scopes #444

Open
pfitzseb opened this issue Nov 23, 2020 · 2 comments
Open

locals doesn't respect macro scopes #444

pfitzseb opened this issue Nov 23, 2020 · 2 comments

Comments

@pfitzseb
Copy link
Member

or something like that.

MWE:

julia> function f()
         @info "info" foo=:bar
         @bp
         x = sin(2.0)
         return x
       end
f (generic function with 1 method)

julia> frame, bp = @interpret f();
┌ Info: info
└   foo = :bar

julia> JuliaInterpreter.locals(frame)
10-element Array{JuliaInterpreter.Variable,1}:
 #self# = f
 level = Info
 std_level = Info
 group = Symbol("REPL[18]")
 _module = Main
 logger = Logging.ConsoleLogger(Base.TTY(RawFD(0x00000019) open, 0 bytes waiting), Info, Logging.default_metafmt, true, 0, Dict{Any,Int64}())
 id = :Main_456f9b5a
 file = "REPL[18]"
 line = 2
 msg = "info"

The immediate cause for that is that those symbols show up in slotnames:

julia> code_lowered(f)[1].slotnames
12-element Array{Symbol,1}:
 Symbol("#self#")
 :level
 :std_level
 :group
 :_module
 :logger
 :id
 :file
 :line
 :x
 :msg
 :err

Not sure how we should go about fixing this.

@KristofferC
Copy link
Member

KristofferC commented Nov 23, 2020

FWIW, I think fixing this is quite hard.

@timholy
Copy link
Member

timholy commented Nov 23, 2020

Agreed that it would be nice to fix but it's not obviously easy or even possible to do cleanly. We might need to have lowering add a field nslots that gives the number of slots prior to macro expansion. (And I'm not sure that would be easy to do either.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants