Skip to content

Make variables defined in try visible from else #46928

@jariji

Description

@jariji

In a try/else I usually want to refer to a variable defined in the try but it's not available unless I put local x before the try.

julia> try
         x = 1
       catch 
         nothing
       else
         println(x)
       end
ERROR: UndefVarError: x not defined
Stacktrace:
 [1] top-level scope
   @ REPL[1]:5

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