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

Error when using "return" before error in gsub #64

Open
Srlion opened this issue Oct 7, 2024 · 1 comment · May be fixed by #65
Open

Error when using "return" before error in gsub #64

Srlion opened this issue Oct 7, 2024 · 1 comment · May be fixed by #65

Comments

@Srlion
Copy link

Srlion commented Oct 7, 2024

return {
    cases = {
        {
            name = "love or hate, you gonna eat it",
            func = function()
                ("s"):gsub("s", function()
                    return error("sfasf")
                end)
            end
        }
    }
}

if you remove the return before error it will work as expected, probably you check if two traces are from C and just skip the rest?

[gluatest] addons/gluatest/lua/gluatest/runner/log_helpers.lua:48: attempt to index local 'testFile' (a nil value)
  1. getFileLines - addons/gluatest/lua/gluatest/runner/log_helpers.lua:48
   2. GetLineWithContext - addons/gluatest/lua/gluatest/runner/log_helpers.lua:97
    3. logCodeContext - addons/gluatest/lua/gluatest/runner/logger.lua:83
     4. logTestCaseFailure - addons/gluatest/lua/gluatest/runner/logger.lua:147
      5. LogTestFailureDetails - addons/gluatest/lua/gluatest/runner/logger.lua:242
       6. setFailed - addons/gluatest/lua/gluatest/runner/runner.lua:36
        7. processCase - addons/gluatest/lua/gluatest/runner/runner.lua:162
         8. runNextTestGroup - addons/gluatest/lua/gluatest/runner/runner.lua:173
          9. runner - addons/gluatest/lua/gluatest/runner/runner.lua:270
           10. runAllTests - addons/gluatest/lua/gluatest/init.lua:64
            11. unknown - addons/gluatest/lua/gluatest/init.lua:73
             12. unknown - lua/includes/modules/concommand.lua:54

@brandonsturgeon
Copy link
Member

So these functions get passed into xpcall, using this error handler which uses this helper function to determine the sourceFile and sourceLine

I'm all ears for better ways to do it - I'll give your specific example a try and see if I can handle situations where the stack is (probably) off-by-one because of the return

@Srlion Srlion linked a pull request Oct 8, 2024 that will close this issue
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.

2 participants