Skip to content

Conversation

@emmachase
Copy link
Contributor

Lua 5.1 and LuaJIT have a bug where it's not possible to specify the level without a message. Previously the stacktrace was just ignored in TSTL for these versions; but we can workaround this bug by just specifying an empty message and trimming the newline with string.sub.

Also:

  • Fix the constructor passed when getting the stacktrace, as constructor.new doesn't seem to exist. I suspect that .new used to be a thing but was never updated when this was changed.
    • Is there any circumstance where finding the __TS__New would result in the wrong level? Since __TS__New is not specifically for Error.
  • I also noticed a typo and what looks like a bug in the testEachVersion util where if it found any target that was disabled, it would completely exit even if other versions were specified.

* Fix the constructor passed when getting the stacktrace
* Fix testEachVersion builder
Copy link
Member

@Perryvw Perryvw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution, looks good aside from the issues the linter seems to be having! You can check for linter errors locally with npm run lint.


if (_VERSION.includes("Lua 5.0")) {
return debug.traceback(`[Level ${level}]`);
} else if (_VERSION === "Lua 5.1") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guess we should use .includes here too, to trick whatever type nonsense is going on with the version-specific types

Copy link
Contributor Author

@emmachase emmachase Jan 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going by the declaration which only seems to have 5.1, I guess includes is used to catch all of the 5.0 subversions. I think I just need to include another @ts-ignore here. This one is my bad since I changed this last minute without running another build.

declare const _VERSION:
    | ('Lua 5.0' | 'Lua 5.0.1' | 'Lua 5.0.2' | 'Lua 5.0.3')
    | 'Lua 5.1'
    | 'Lua 5.2'
    | 'Lua 5.3'
    | 'Lua 5.4';

...util.expectEachVersionExceptJit(builder => {
builder.expectToHaveNoDiagnostics();
const luaResult = builder.getLuaExecutionResult();
expect(luaResult.split('\n').length).toBe(4);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ugh, linter seems confused about our helper function here. I don't like it but I guess you can add // eslint-disable-next-line jest/no-standalone-expect here

@emmachase
Copy link
Contributor Author

Thanks for the comments, I totally forgot to run lint, I was assuming it would run alongside build. Will address these.

@emmachase
Copy link
Contributor Author

Should be good now :)

@Perryvw Perryvw merged commit b706a85 into TypeScriptToLua:master Jan 16, 2025
5 checks passed
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