mirror of
https://github.com/Hilbis/Hilbish
synced 2025-04-21 13:03:22 +00:00
fix: add names at chunk load for context in errors
This commit is contained in:
parent
50f703d9b3
commit
8a34783fee
@ -42,7 +42,7 @@ func SetField(rtm *rt.Runtime, module *rt.Table, field string, value rt.Value, d
|
||||
|
||||
// DoString runs the code string in the Lua runtime.
|
||||
func DoString(rtm *rt.Runtime, code string) error {
|
||||
chunk, err := rtm.CompileAndLoadLuaChunk("", []byte(code), rt.TableValue(rtm.GlobalEnv()))
|
||||
chunk, err := rtm.CompileAndLoadLuaChunk("<string>", []byte(code), rt.TableValue(rtm.GlobalEnv()))
|
||||
if chunk != nil {
|
||||
_, err = rt.Call1(rtm.MainThread(), rt.FunctionValue(chunk))
|
||||
}
|
||||
@ -92,7 +92,12 @@ func DoFile(rtm *rt.Runtime, path string) error {
|
||||
buf = append(buf, line...)
|
||||
}
|
||||
|
||||
return DoString(rtm, string(buf))
|
||||
chunk, err := rtm.CompileAndLoadLuaChunk(path, buf, rt.TableValue(rtm.GlobalEnv()))
|
||||
if chunk != nil {
|
||||
_, err = rt.Call1(rtm.MainThread(), rt.FunctionValue(chunk))
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// HandleStrCallback handles function parameters for Go functions which take
|
||||
|
Loading…
x
Reference in New Issue
Block a user