Skip to content

fix(stdlib): load honours its chunkname in errors and tracebacks - #427

Closed
shinyobjectz wants to merge 1 commit into
tv-labs:mainfrom
OpenRelationship:fix/load-chunkname
Closed

shinyobjectz wants to merge 1 commit into
tv-labs:mainfrom
OpenRelationship:fix/load-chunkname

Conversation

@shinyobjectz

Copy link
Copy Markdown

load(chunk, chunkname) ignored chunkname, so any error raised inside a loaded chunk read -no-source-:N: .... Hosts that load files through load, for example a require built over a virtual filesystem, can't tell a user which file failed.

This passes the chunk name to the compiler as Lua's luaO_chunkid shows it:

  • "@file" → file
  • "=name" → name
  • any other string → [string "its first line"]

A syntax error from load is prefixed with the same name. Without a chunkname, behaviour is unchanged.

Tests are in test/language/load_test.exs. The full suite passes (2874 passed).

load(chunk, chunkname) ignored chunkname, so every error raised in a loaded
chunk read "-no-source-:N: ...". Now the chunk takes its name as Lua's
luaO_chunkid shows it: "@file" is the file, "=name" is used as is, any
other string is [string "its first line"]. A syntax error is prefixed with
the same name. Without a chunkname nothing changes.
@OpenRelationship OpenRelationship closed this by deleting the head repository Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants