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

xpcall with error in error handler returns (nil, nil) #452

Closed
2 tasks done
mzki opened this issue Aug 12, 2023 · 0 comments · Fixed by #453
Closed
2 tasks done

xpcall with error in error handler returns (nil, nil) #452

mzki opened this issue Aug 12, 2023 · 0 comments · Fixed by #453

Comments

@mzki
Copy link
Contributor

mzki commented Aug 12, 2023

You must post issues only here. Questions, ideas must be posted in discussions.

  • GopherLua is a Lua5.1 implementation. You should be familiar with Lua programming language. Have you read Lua 5.1 reference manual carefully?
  • GopherLua is a Lua5.1 implementation. In Lua, to keep it simple, it is more important to remove functionalities rather than to add functionalities unlike other languages . If you are going to introduce some new cool functionalities into the GopherLua code base and the functionalities can be implemented by existing APIs, It should be implemented as a library.

Please answer the following before submitting your issue:

  1. What version of GopherLua are you using? : 2b3f02d
  2. What version of Go are you using? : go version go1.19.12 linux/amd64
  3. What operating system and processor architecture are you using? : See 2.
  4. What did you do? :
  5. What did you expect to see? :
    xpcall with error in error handler returns (false, error-object).
/ # lua
Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
> ok, msg = xpcall(function() error("fn") end, function(err) error("handler") end)
> print(ok, msg)
false   error in error handling
> function test()
>>   xpcall(function() error("fn") end, function(err) error("handler") end)
>>   error("expected to reach this")
>> end
> test()
stdin:3: expected to reach this
stack traceback:
        [C]: in function 'error'
        stdin:3: in function 'test'
        stdin:1: in main chunk
        [C]: ?
>
  1. What did you see instead? :
    xpcall with error in error handler returns (nil, nil).
    In addition, xpcall exits current function scope and interpreter does not execute next line.
/workspaces/gopher-lua/cmd/glua# ./glua 
GopherLua 0.1 Copyright (C) 2015 -2017 Yusuke Inuzuka
> ok, msg = xpcall(function() error("fn") end, function(err) error("handler") end)
> print(ok, msg)
nil     nil
> function test()
>>   xpcall(function() error("fn") end, function(err) error("handler") end)
>>   error("expected to reach this")
>> end
> test()
> 

Although the behavior of xpcall with error in error handler is not well described in the reference, but it is better to be compatible with CLua5.1 behavior.

mzki added a commit to mzki/gopher-lua that referenced this issue Aug 12, 2023
@yuin yuin closed this as completed in #453 Nov 4, 2023
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 a pull request may close this issue.

1 participant