Skip to content

Commit 93007a6

Browse files
committed
invert atan2 condition to default future Lua targets to math.atan
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.
1 parent 9935e8d commit 93007a6

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/transformation/builtins/math.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,13 @@ export function transformMathCall(
4949
return transformLuaLibFunction(context, LuaLibFeature.MathAtan2, node, ...params);
5050
}
5151

52-
const useAtan =
53-
context.luaTarget === LuaTarget.Lua53 ||
54-
context.luaTarget === LuaTarget.Lua54 ||
55-
context.luaTarget === LuaTarget.Lua55;
56-
const method = lua.createStringLiteral(useAtan ? "atan" : "atan2");
52+
const useAtan2 =
53+
context.luaTarget === LuaTarget.Lua50 ||
54+
context.luaTarget === LuaTarget.Lua51 ||
55+
context.luaTarget === LuaTarget.Lua52 ||
56+
context.luaTarget === LuaTarget.LuaJIT ||
57+
context.luaTarget === LuaTarget.Luau;
58+
const method = lua.createStringLiteral(useAtan2 ? "atan2" : "atan");
5759
return lua.createCallExpression(lua.createTableIndexExpression(math, method), params, node);
5860
}
5961

0 commit comments

Comments
 (0)