Repository navigation
Reject an integer returned from a real Jass function - #1491
Conversation
pjass rejects it, so only an inlined call compiled, and there f(n) / m became the integer division n / m. Report it at type check as for Wurst source; a warning for legacy targets.
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f3069aaa88
ℹ️ 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".
…does A legacy target accepts the return with a warning. The inliner leaves such a function a call, where the integer becomes the declared real. The test harness skips pjass for a legacy target, as a build does.
type myint extends integer returned as real, and an integer returned as type myreal extends real, are the same pjass error.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 873d354b95
ℹ️ 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".
The IM names a derived native type only by its own name, so the inliner could not tell type myint extends integer from another type. The translation, which has the Jass types, marks such a function, and the inliner keeps it a call.
|
@codex review |
|
Codex Review: Didn't find any major issues. 🚀 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". |
Jass code accepts an integer wherever a real is expected, returns included. pjass rejects an integer returned from a function declared to return a real ("Cannot convert returned value from integer to real"), so such a function only got through a build when every call to it was inlined. Inlining removed the return, and with it the conversion, so
f(n) / mbecame the integer divisionn / m.type myint extends integer) count as integer or real, as they do for pjass. Integers stored into or passed as reals are still accepted, as pjass accepts them.legacyJassTypeChecks, no pjass) it is a warning, like the other Jass return mismatches. The IM translation, which still has the Jass types, flags such a function and the inliner leaves it a call: inlined, the integer would land in an operand. I chose that over splicing an explicit conversion because it changes nothing for valid code. How the legacy engine treats such a return is unmeasured.Measured on the 3.0.0 client (3.0.0.24268). The probe is
function f takes integer n returns real / return nandf(n) / mwith n = 7 and m = 2, read from an array at run time and built with-inline -localOptimizationsin Jass mode:set a = n / mand gives 3 (an integer division; 3.5 expected)Tests: CompilationUnitTests (int, literal and derived-type returns are errors, a warning for legacy targets, int stored or passed as real is OK) and OptimizerTests.inlinerKeepsALegacy(Derived)IntReturnedAsRealACall (red without the change). CompilationUnitTests, BugTests and OptimizerTests pass locally on Windows. The change has no host-specific code; other platforms were not run locally.