TIC-80 icon indicating copy to clipboard operation
TIC-80 copied to clipboard

trace errors when given empty args

Open ian5 opened this issue 2 years ago • 10 comments

Lua is a little strange about the dichotomy between nil and no value. In most cases they're treated to be the same, however in two specific cases (probably more, but two of note here), this isn't the case: passing arguments to C functions, and returning no value.

Normal lua isn't the cleanest about this either; tostring() errors while print() does nothing.

Ideally, I think that trace should handle any input, including nothing, gracefully. As of now, trace() is an error.

There's a few less explicit cases than trace() though:

function noValue()
 if false then
  return 4
 end
 --implicitly runs a "return" with no
 --value
end

trace(noValue())

errors, while

function noValue()
 if false then
  return 4
 end
 --implicitly runs a "return" with no
 --value
end

someValue = no_value()

trace(someValue)

prints nil

This is a fairly obscure issue, but it caused me some headaches while debugging, so I figured I'd report it.

ian5 avatar Jan 09 '22 01:01 ian5