0110: Function must return N values

Compiler found that number of values in return statement does not match function signature. It can happen if return has more or fewer values.

For example, if function has not declared any return type, it's incorrect to return values from it:

function foo
  return 1 // error, `foo` should return nothing
end

Similarly, it is incorrect to return nothing, when the function has declared a return type:

function bar: int
  return
end

Possible solutions:

  • check a number of returned values following a return keyword. Make sure this number matches the number of return types declared in the function's signature

  • if the function may, under some condition, return nothing (a fallible function), its return type must be prepended with an optional keyword:

function bar: optional int
  if ...
  then
    return 1
  else
   return
  end
end

Last updated