Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to check incompatible types of the return values of if and else arms #351

Open
sychoo opened this issue Sep 2, 2019 · 0 comments
Open

Comments

@sychoo
Copy link
Contributor

sychoo commented Sep 2, 2019

The following code should throw an error stating that "if and else have incompatible types". However, it executes successfully.

require stdout  
def number(n:Int):Int
    if (n == 1)
        1
      else
        "other numbers"
stdout.printInt(number(1))

The following code should also throw an error stating that "if and else have incompatible types". However, there is a runtime error coming from the printInt function: "No applicable method "printInt"".

require stdout
def number(n:Int):Int
    if (n == 1)
        1
      else
        "other numbers"
stdout.printInt(number(2))

Exception in thread "main" java.lang.RuntimeException: no applicable method 'printInt'! at wyvern.tools.interop.JObject.invokeMethod(JObject.java:50) at wyvern.tools.interop.JavaValue.invoke(JavaValue.java:58) at wyvern.target.corewyvernIL.expression.MethodCall$1.interpret(MethodCall.java:167) at wyvern.target.corewyvernIL.expression.MethodCall.trampoline(MethodCall.java:183) at wyvern.target.corewyvernIL.expression.MethodCall.interpret(MethodCall.java:178) at wyvern.target.corewyvernIL.expression.SeqExpr.interpretCtx(SeqExpr.java:193) at wyvern.target.corewyvernIL.expression.SeqExpr.interpret(SeqExpr.java:224) at wyvern.tools.Interpreter.main(Interpreter.java:90)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant