Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3246,7 +3246,8 @@ class Interpreter {
case UOP_MINUS: scratch = makeNumber(-scratch.v.d); break;

case UOP_BITWISE_NOT:
scratch = makeNumber(~(long)(scratch.v.d));
scratch = makeNumber(
~safeDoubleToInt64(scratch.v.d, ast.location));
break;

default:
Expand Down
3 changes: 3 additions & 0 deletions test_suite/error.integer_bitwise_not.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Value just beyond MAX_SAFE_INTEGER (2^53 - 1)
local beyond_max = 9007199254740992; // 2^53
~beyond_max // Should throw error "numeric value outside safe integer range for bitwise operation"
2 changes: 2 additions & 0 deletions test_suite/error.integer_bitwise_not.jsonnet.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
RUNTIME ERROR: numeric value outside safe integer range for bitwise operation.
error.integer_bitwise_not.jsonnet:3:1-12
Loading