0109: Expected variables to store function result

Compiler expected a certain number of variables to store the result of the function but got different number.

If a function returns one value, the following code will be invalid:

function returnOne: int
  return 1
end

int x,y


returnOne() // error, expected 1 variable, got 0
x,y = returnOne() // error, expected 1 variable, got 2

Possible solutions:

  • on the left-hand side of the expression, provide variables to store each value returned from the function, if there are any

function returnNone
end

function returnOne: int
  return 1
end

function returnTwo: int, int
  return 1 2
end

int x, y

returnNone()
x = returnOne()
x, y = returnTwo()

Last updated