Skip to content

Local variable inside closure signature gets hoisted to wrong scope #56711

Closed
@Keno

Description

@Keno
julia> function fs()
                  f(lhs::Integer) = 1
                  f(lhs::Integer, rhs::(local x=Integer; x)) = 2
                  return f
              end
fs (generic function with 1 method)

julia> x
Integer

This is supposed to end up as a local of the toplevel thunk, but it becomes a global instead. It's fine if there's only one method definition of the closure:

julia> function fs()
                  f(lhs::Integer, rhs::(local x=Integer; x)) = 2
                  return f
              end
fs (generic function with 1 method)

julia> x
ERROR: UndefVarError: `x` not defined in `Main`
Suggestion: check for spelling errors or missing imports.

Metadata

Metadata

Assignees

No one assigned

    Labels

    compiler:loweringSyntax lowering (compiler front end, 2nd stage)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions