fix Math.atan2 emitting math.atan2 instead of math.atan for Lua 5.4+#1700
Merged
Perryvw merged 2 commits intoTypeScriptToLua:masterfrom Apr 1, 2026
Merged
Conversation
math.atan2 was removed in Lua 5.3 (replaced by two-arg math.atan). The codegen only special-cased 5.3 but not 5.4 or 5.5, which also lack math.atan2 (5.4 has it behind a compat flag, 5.5 drops it).
Enumerate the older targets that need math.atan2 instead of the newer ones that need math.atan, so any future Lua target (5.6+) defaults to the modern behavior rather than silently regressing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Math.atan2(y, x)emitsmath.atan2(y, x)for Lua 5.4 and 5.5 targets, butmath.atan2was deprecated in 5.3 (replaced by two-argmath.atan(y, x)). 5.3 still has both, and 5.4 keepsmath.atan2behind-DLUA_COMPAT_5_3(hardcoded in the stock Makefile). 5.5 drops the compat flag, somath.atan2is justniland you get a runtime error.The codegen only special-cased
=== Lua53when choosingmath.atanvsmath.atan2. That was correct when written (2019, before 5.4/5.5 targets existed) but never got updated when those targets were added.Tests didn't catch this because
getLuaBindingsForVersionin test/util.ts falls through to the 5.4 WASM for 5.5, and the 5.4 WASM is built with compat enabled, somath.atan2exists and the test passes.