wyvernlang / wyvern

The Wyvern programming language.

Home Page:http://wyvernlang.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can’t use arrow types in module defs

JonathanAldrich opened this issue · comments

(copied from an email)

Here is the issue that I see when I try to use an arrow type in the header of a resource module.

main.wyv // top-level code
import m
val m = m(() => unit)
m.run()

m.wyv
module def m(methodToRun: Unit -> Unit)
import debug
def run(): Unit
methodToRun()
debug.print("Testing module m.\n")

When I run this code, I get the following runtime exception:
$ ./wyvern main.wyv
Exception in thread "main" java.lang.ClassCastException: wyvern.tools.types.extensions.Arrow cannot be cast to wyvern.tools.types.NamedType
at wyvern.tools.typedAST.core.declarations.ModuleDeclaration.getTypes(ModuleDeclaration.java:111)
at wyvern.tools.typedAST.core.declarations.ModuleDeclaration.topLevelGen(ModuleDeclaration.java:217)
at wyvern.target.corewyvernIL.support.ModuleResolver.loadContinuation(ModuleResolver.java:303)
at wyvern.target.corewyvernIL.support.ModuleResolver.load(ModuleResolver.java:400)
at wyvern.target.corewyvernIL.support.ModuleResolver.resolveModule(ModuleResolver.java:199)
at wyvern.tools.typedAST.core.declarations.ImportDeclaration.genBinding(ImportDeclaration.java:248)
at wyvern.tools.typedAST.core.declarations.ImportDeclaration.genBinding(ImportDeclaration.java:137)
at wyvern.tools.typedAST.core.declarations.ImportDeclaration.genTopLevel(ImportDeclaration.java:296)
at wyvern.tools.typedAST.core.Script.generateTLC(Script.java:45)
at wyvern.tools.typedAST.core.Script.generateIL(Script.java:58)
at wyvern.target.corewyvernIL.support.ModuleResolver.loadContinuation(ModuleResolver.java:301)
at wyvern.target.corewyvernIL.support.ModuleResolver.load(ModuleResolver.java:400)
at wyvern.target.corewyvernIL.support.ModuleResolver.load(ModuleResolver.java:384)
at wyvern.tools.Interpreter.main(Interpreter.java:61)

Was partially fixes in PR #341. Created issue #345 for the remainder. Closing this issue.