silver icon indicating copy to clipboard operation
silver copied to clipboard

Variable scope with nested scopes

Open Aurel300 opened this issue 1 year ago • 0 comments

(Reported by a PV student:)

method test() {
    {
        var i: Int
    }
    var i: Int
}

This causes an AST construction error for the second declaration of i, because it is seen as a duplicate. This is a little strange, and I would expect either:

  • The error to be associated with the inner i, because the outer declaration is hoisted to the beginning of the outer scope.
  • There to be no error, because when the outer i is declared, the inner i is no longer in scope.

Aurel300 avatar May 04 '24 08:05 Aurel300