kyren / piccolo

An experimental stackless Lua VM implemented in pure Rust
Creative Commons Zero v1.0 Universal
1.68k stars 63 forks source link

Problem with multiple return values and assignments #18

Closed jugglerchris closed 5 years ago

jugglerchris commented 5 years ago

I've noticed that assignments with functions with multiple return values doesn't work. For example:

function mulret()
    return 1,2,3
end

a,b,c = mulret()
print(a,b,c)

In lua gives:

1       2       3

In Luster:

1       nil     nil

I think the problem is in the handling of assigment statements in the compiler, which seems not to have allowed for multiple returns yet (the function is called with 1 expected return value).

kyren commented 5 years ago

Oh, it might only work with local statements, not with assignment. I'll look into this, thank you!

kyren commented 5 years ago

I think I just somehow forgot to do this when implementing the compiler, should be fixed now by 8549771

jugglerchris commented 5 years ago

Great, thanks! That was quick.