rsdn / nitra

Nitra is a language workbench

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AST: "as" pattern in "when"- and "unless"-clause does not bind to the variable

ssrmm opened this issue · comments

commented

Despite being declared in the when-condition, the variable Foo1 is not actually visible and the compiler produces an error message. This happens with unless as well.

using Nitra;

namespace Test
{
  ast TestAst
  {
    when(Foo is Test.Foo as Foo1)
      Error(context, "Cannot be Foo(" + Foo1.Integer + "), must be Bar."); // error : unbound name `Foo1'

    out Foo : Test = Test.Foo(1);
  }

}
namespace Test
{
  public variant Test
  {
    | Foo { Integer : int;   }
    | Bar { Float   : float; }
  }
}