wyvernlang/wyvern

Match broken on datatypes in other modules

hcnelson99 opened this issue · 0 comments

Test case:

test.wyv:

import foo

val e = foo.Bar(unit)

match e:
    x: foo.Bar => unit

foo.wyv:

module foo

datatype Foo
    Bar(baz: Unit)

Observed behavior:

Exception in thread "main" java.lang.RuntimeException: Variable var_23 not found
	at wyvern.target.corewyvernIL.support.EmptyValContext.lookupValue(EmptyValContext.java:9)
	at wyvern.target.corewyvernIL.support.VarEvalContext.lookupValue(VarEvalContext.java:31)
	at wyvern.target.corewyvernIL.support.VarEvalContext.lookupValue(VarEvalContext.java:31)
	at wyvern.target.corewyvernIL.support.VarEvalContext.lookupValue(VarEvalContext.java:31)
	at wyvern.target.corewyvernIL.support.VarEvalContext.lookupValue(VarEvalContext.java:31)
	at wyvern.target.corewyvernIL.support.VarEvalContext.lookupValue(VarEvalContext.java:31)
	at wyvern.target.corewyvernIL.support.VarEvalContext.lookupValue(VarEvalContext.java:31)
	at wyvern.target.corewyvernIL.support.VarEvalContext.lookupValue(VarEvalContext.java:31)
	at wyvern.target.corewyvernIL.support.VarEvalContext.lookupValue(VarEvalContext.java:31)
	at wyvern.target.corewyvernIL.support.VarEvalContext.lookupValue(VarEvalContext.java:31)
	at wyvern.target.corewyvernIL.support.VarEvalContext.lookupValue(VarEvalContext.java:31)
	at wyvern.target.corewyvernIL.support.VarEvalContext.lookupValue(VarEvalContext.java:31)
	at wyvern.target.corewyvernIL.support.VarEvalContext.lookupValue(VarEvalContext.java:31)
	at wyvern.target.corewyvernIL.support.VarEvalContext.lookupValue(VarEvalContext.java:31)
	at wyvern.target.corewyvernIL.support.VarEvalContext.lookupValue(VarEvalContext.java:31)
	at wyvern.target.corewyvernIL.support.VarEvalContext.lookupValue(VarEvalContext.java:31)
	at wyvern.target.corewyvernIL.expression.Variable.interpret(Variable.java:109)
	at wyvern.target.corewyvernIL.type.NominalType.getTag(NominalType.java:297)
	at wyvern.target.corewyvernIL.expression.Tag.getParent(Tag.java:31)
	at wyvern.target.corewyvernIL.expression.Tag.isSubTag(Tag.java:21)
	at wyvern.target.corewyvernIL.expression.Match.interpret(Match.java:123)
	at wyvern.target.corewyvernIL.expression.SeqExpr.interpretCtx(SeqExpr.java:168)
	at wyvern.target.corewyvernIL.expression.SeqExpr.interpret(SeqExpr.java:199)
	at wyvern.tools.Interpreter.main(Interpreter.java:72)

Expected behavior: Clean compilation.

Note: The issue goes away when modules aren't used. The following works properly:

datatype Foo
    Bar(baz: Unit)

val e = Bar(unit)

match e:
    x: Bar => unit