wyvernlang/wyvern

Effects in .wyt file with imports do not compile

Closed this issue · 0 comments

I cannot import wyvern.option and have an effect in a datatype in the same .wyt file. For example, the following code does not compile (given the filename T.wyt):

import wyvern.option

type T
  effect A
  def foo() : option.Option[Int]

The compiler gives the following Java error for this snippet of code:

Exception in thread "main" java.lang.NullPointerException
        at wyvern.target.corewyvernIL.decltype.EffectDeclType.doAvoid(EffectDeclType.java:158)
        at wyvern.target.corewyvernIL.type.StructuralType.doAvoid(StructuralType.java:277)
        at wyvern.target.corewyvernIL.type.StructuralType.doAvoid(StructuralType.java:28)
        at wyvern.target.corewyvernIL.decltype.ConcreteTypeMember.doAvoid(ConcreteTypeMember.java:126)
        at wyvern.target.corewyvernIL.decltype.ConcreteTypeMember.doAvoid(ConcreteTypeMember.java:17)
        at wyvern.target.corewyvernIL.type.StructuralType.doAvoid(StructuralType.java:277)
        at wyvern.target.corewyvernIL.type.ValueType.avoid(ValueType.java:153)
        at wyvern.target.corewyvernIL.expression.SeqExpr.typeCheck(SeqExpr.java:110)
        at wyvern.target.corewyvernIL.support.ModuleResolver.createAdaptedModule(ModuleResolver.java:309)
        at wyvern.target.corewyvernIL.support.ModuleResolver.load(ModuleResolver.java:302)
        at wyvern.tools.Interpreter.main(Interpreter.java:61)

Having foo simply return at Int results in the same error. Making A not abstract does not work, either. The following code still does not compile:

import wyvern.option

type T
  effect A = {}
  def foo() : option.Option[Int]

The error returned by the compiler this time is:

Exception in thread "main" java.lang.NullPointerException
        at wyvern.target.corewyvernIL.decltype.EffectDeclType.equals(EffectDeclType.java:125)
        at java.util.AbstractList.equals(AbstractList.java:523)
        at wyvern.target.corewyvernIL.type.StructuralType.equals(StructuralType.java:301)
        at wyvern.target.corewyvernIL.decltype.ConcreteTypeMember.doAvoid(ConcreteTypeMember.java:127)
        at wyvern.target.corewyvernIL.decltype.ConcreteTypeMember.doAvoid(ConcreteTypeMember.java:17)
        at wyvern.target.corewyvernIL.type.StructuralType.doAvoid(StructuralType.java:277)
        at wyvern.target.corewyvernIL.type.ValueType.avoid(ValueType.java:153)
        at wyvern.target.corewyvernIL.expression.SeqExpr.typeCheck(SeqExpr.java:110)
        at wyvern.target.corewyvernIL.support.ModuleResolver.createAdaptedModule(ModuleResolver.java:309)
        at wyvern.target.corewyvernIL.support.ModuleResolver.load(ModuleResolver.java:302)
        at wyvern.tools.Interpreter.main(Interpreter.java:61)

If the wyvern.option import is removed, then both of the above examples work. Furthermore, if the effect A or effect A = {} is commented out in the above examples (while keeping the wyvern.option import), the examples also work.