Re: Confusing error message if error is in return statement of a member function.

  • From: Mike Pall <mike-1502@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Sun, 22 Feb 2015 17:46:49 +0100

Julian Schrittwieser wrote:
> function Foo:bar(numbers)
>   return math.max(numbers)
> end

We had a similar discussion about tail calls just a couple days
ago with 'return setfenv()'.

In short: tail calls are a core language feature of Lua and not an
optimization (like in other languages). If you don't like them due
to their side effects on debugging (which is, destroying the original
frame info), then you can easily avoid them with parentheses.

Here's an older thread with a longer explanation:

//www.freelists.org/post/luajit/Bad-stack-trace-from-lua-getstack-and-lua-getinfo,1

--Mike

Other related posts: