Example program:

{
  a++;
  int a;
}
a++;

Example AST:

Program(
  BlockStatement(
    Increment("a")
  , IntDef("a")
  )
, Increment("a")
)

Semantics:
- The first a++ should give an error because there is a variable use before it’s definition.
- The second a++ should not give an error because block statements don’t scope variables.

The following NaBL definition should model these semantics:

IntDef(v):
  defines Var v in subsequent scope

Increment("a"):
  refers to Var v

However, the second a++ unexpectedly produces an error: unresolved reference. I understood from Gabriel that this may be a problem in the implementation of subsequent scoping: a scoping annotation is added to the parent term (in this case BlockStatement(....), and the name is therefore only visible inside the parent term. However, it should be visible outside the parent term too.

Would be great if this could be improved.

Submitted by Oskar van Rest on 16 September 2014 at 00:24

Log in to post comments