Commit 34e2b63
committed
fix: mask left shifts in numeric fast path
Motivation:
Jsonnet interprets shift counts modulo 64, but the numeric fast path validated
left shifts using the unmasked count. Expressions routed through outer
arithmetic could therefore fail even when the generic evaluator succeeded.
Modification:
Normalize non-negative left-shift counts modulo 64 before both overflow
validation and execution, and add regressions for counts 64, 65, and 128.
Result:
Numeric fast-path behavior now matches the generic evaluator, go-jsonnet,
jrsonnet, and the Jsonnet specification without changing valid count-65
behavior.
References:
- #1096
- https://jsonnet.org/ref/spec.html1 parent a638dc4 commit 34e2b63
3 files changed
Lines changed: 10 additions & 2 deletions
File tree
- sjsonnet
- src/sjsonnet
- test/resources/new_test_suite
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
894 | 894 | | |
895 | 895 | | |
896 | 896 | | |
897 | | - | |
| 897 | + | |
| 898 | + | |
898 | 899 | | |
899 | | - | |
| 900 | + | |
900 | 901 | | |
901 | 902 | | |
902 | 903 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
0 commit comments