mindcode icon indicating copy to clipboard operation
mindcode copied to clipboard

Case expression as a function argument compiles incorrectly

Open cardillan opened this issue 1 year ago • 0 comments

A case expression used as a function argument is compiled into two arguments:

print(case 1 when 1 then 2 end)

produces

set __tmp0 2
print 1
print __tmp0
end

When used with user defined function

def foo(n) print(n) end
foo(case 1 when 1 then 2 end)

an error is reported: "Function 'foo': wrong number of arguments (expected 1, found 2)" (Note: the error is only displayed in the command line application).

cardillan avatar Jul 18 '23 22:07 cardillan