aardappel / lobster

The Lobster Programming Language
http://strlen.com/lobster
2.25k stars 119 forks source link

Specifying function return types results in an error #197

Closed AntonBogun closed 1 year ago

AntonBogun commented 2 years ago

The following code

def f() -> [int],int:
    let a=[1]
    return a,1
def f2(l) -> void:
    print(l)
f2(f())

results in the error run.lobster(3): error: `return` requires type `([int], int)`, got `[int]` However, removing -> [int],int results in no error and the expected behaviour - printout of [1].

aardappel commented 2 years ago

Ahh.. that's because you're calling it in a way that takes only 1 return value, which then removes the 1 and then afterwards complains about it :)

AntonBogun commented 2 years ago

So not intended?

aardappel commented 2 years ago

No, this should compile.

aardappel commented 2 years ago

Should be fixed here: https://github.com/aardappel/lobster/commit/76fa822cb297de5791fb907e4950a7ec346b9eef