Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use debug.traceback for stack traces in Lua-based carts. #2705

Merged
merged 1 commit into from
Oct 16, 2024

Conversation

technomancy
Copy link
Contributor

Fennel carts have debug.traceback set to fennel.traceback during initialization, which is a function that uses sourcemaps to convert the traceback data which Lua knows about (with line numbers based on the Lua output from the Fennel compiler) into traceback data based on line numbers in the original source code.

Previously this had no effect because debug.traceback was never actually run; luaapi.c contained a call to the underlying luaL_traceback function instead, which did not know about sourcemaps. Replacing it with a call to debug.traceback allows us to see stack traces that use sourcemap data.

This change should have no effect on Lua carts; only Fennel carts and perhaps Moonscript carts.

Also in this patch we set the filename field when compiling Fennel carts; without this the custom fennel.traceback function can't use sourcemaps as needed.

Fennel carts have debug.traceback set to fennel.traceback during
initialization, which is a function that uses sourcemaps to convert
the traceback data which Lua knows about (with line numbers based on
the Lua output from the Fennel compiler) into traceback data based on
line numbers in the original source code.

Previously this had no effect because debug.traceback was never
actually run; luaapi.c contained a call to the underlying
luaL_traceback function instead, which did not know about
sourcemaps. Replacing it with a call to debug.traceback allows
us to see stack traces that use sourcemap data.

This change should have no effect on Lua carts; only Fennel carts and
perhaps Moonscript carts.

Also in this patch we set the filename field when compiling Fennel
carts; without this the custom fennel.traceback function can't use
sourcemaps as needed.
@nesbox nesbox merged commit 8e19cb6 into nesbox:main Oct 16, 2024
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants