Repository navigation
Issue #547 : debug.getinfo reports source and short_src as Lua 5.1 - #550
Open
eldologuzzo wants to merge 1 commit into
Open
eldologuzzo wants to merge 1 commit into
eldologuzzo wants to merge 1 commit into
Conversation
A function loaded with LoadFile (dofile, loadfile, require) reports its source as "@" + file name; chunks loaded with a name keep it; a Go function reports "=[C]". short_src is added, built like luaO_chunkid. Error messages and FunctionProto.SourceName do not change. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
Lua’s loadfile still bypasses the new file-origin marker and returns an unprefixed source.
1 open finding
What changed in this PR
Aligns debug.getinfo source reporting with Lua 5.1.
Changes:
- Marks file-loaded function prototypes and prefixes their debug source with
@. - Adds
short_srcgeneration and C-function source reporting. - Expands Lua debug-library tests.
| File | Description |
|---|---|
state.go |
Updates debug source reporting. |
_state.go |
Mirrors state debug changes. |
function.go |
Adds the file-origin marker. |
debuglib.go |
Adds short_src generation. |
auxlib.go |
Marks prototypes loaded through LoadFile. |
_glua-tests/db.lua |
Tests Lua 5.1-compatible sources. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+390
to
+391
| if err == nil && len(path) > 0 { | ||
| markLoadedFromFile(fn.Proto) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #547 .
Changes proposed in this pull request:
debug.getinforeportssourceas Lua 5.1 does:LoadFile(dofile,loadfile,require) gets"@" + file name;"=name","@name");"=[C]".short_srcfield, built likeluaO_chunkid:"@f.lua"givesf.lua,"=name"givesname, and anything else gives[string "first line..."].FunctionProto.SourceNameand error messages do not change. The chunks are marked inLoadFilewith an unexported field._glua-tests/db.luaasserted the previous GopherLua-specificsource == "db.lua". It now asserts"@db.lua"andshort_src == "db.lua", as in Lua 5.1, and adds cases for Go functions and named chunks. The new assertions pass on Lua 5.1.5.🤖 Generated with Claude Code