Repository navigation
Convert a unary expression handed to an old generic once on Lua - #1536
Conversation
An argument, closure result or block result such as -2.5 for an old generic parameter was converted to the erased index twice on Lua: the operand took the generic's conversion as well as the result, so realToIndex(-(realToIndex(2.5))) read back as -2500, and -(c ? 1. : 2.) as -1000. The operand now takes the operator's own type and only the result converts.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f2e0ffd274
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…erics The regression test also checks the emitted Lua: no unary operand converts to the erased index, and the negated real and boolean convert once. A new-generic counterpart hands the same unary expressions to a <T:> function, closure and class and checks that they go through no index.
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
On Lua, a unary expression whose value goes to an old generic
<T>was converted to the erased index twice. This covers an argument, a closure's result or a block's result:-2.5,not bor-(c ? 1. : 2.). The operand took the generic's conversion, and then so did the result. Soid<real>(-2.5)printed asrealToIndex(-(realToIndex(2.5)))and read back as -2500, andlist.add(-2.)stored -2000. Jass and the interpreter were right. Jass printsrealToIndex( - 2.).Cause. In
imtranslation/ExprTranslation.translateWithExpectedType, theExprUnarycase passed the expected type to its operand. That path only runs for Lua.Fix. The operand now takes the operator's own type, from its own expected type. Only the result converts to what the context expects.
Test.
LuaBackendAuditTests.unaryExpressionPassedToAnOldGenericIsConvertedOnceruns on Jass and Lua. It covers:not;addandmap;-b.v), which master already handled and an earlier version of this fix broke.The test fails with master's translator ("Succeed function not called") and passes with the fix.
LuaBackendAuditTests,LuaTranslationTests,GenericsTests,ClosureTests,LuaTypecastingTestsandExpressionTestspass. Only Windows was run.