Skip to content

fix: correct std.atan2 parameter names to match spec#905

Merged
stephenamar-db merged 1 commit into
databricks:masterfrom
He-Pin:fix/atan2-param-names
Jun 9, 2026
Merged

fix: correct std.atan2 parameter names to match spec#905
stephenamar-db merged 1 commit into
databricks:masterfrom
He-Pin:fix/atan2-param-names

Conversation

@He-Pin

@He-Pin He-Pin commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fix std.atan2 parameter names from ("x", "y") to ("y", "x") matching the Jsonnet spec std.atan2(y, x)
  • Named argument calls like std.atan2(y=1, x=0) now produce correct results

std.atan2(y, x) (available since 0.21.0)

Verification against go-jsonnet

$ echo 'std.atan2(y=1, x=0)' | jsonnet -
1.5707963267948966

$ echo 'std.atan2(y=0, x=1)' | jsonnet -
0

sjsonnet now produces identical results.

Test plan

  • Added StdMathTests.atan2 named parameters test
  • Verified positional call behavior unchanged
  • Cross-checked with go-jsonnet binary

Motivation:
The Jsonnet spec defines std.atan2(y, x) but the parameter names were
declared as "x", "y" causing named argument calls like std.atan2(y=1, x=0)
to produce incorrect results.

Modification:
Swap parameter names from ("x", "y") to ("y", "x") in the builtin
declaration to match the spec.

Result:
Named argument calls now work correctly: std.atan2(y=1, x=0) returns π/2.
builtin("atan2", "x", "y") { (pos, ev, x: Double, y: Double) =>
math.atan2(x, y)
builtin("atan2", "y", "x") { (pos, ev, y: Double, x: Double) =>
math.atan2(y, x)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

std.atan2(y, x) (available since 0.21.0)

Just checked

@stephenamar-db stephenamar-db merged commit d1dbb8d into databricks:master Jun 9, 2026
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