karatelabs/karate · error · JsErrorException (typeError)
BigInts have no unsigned right shift, use >> instead
Error message
BigInts have no unsigned right shift, use >> instead
What it means
A TypeError implementing the spec rule that BigInt has no unsigned right shift operator: `>>>` always throws for BigInt operands, even when both sides are BigInt, because the semantics are undefined for arbitrary-precision integers. The message tells you to use the signed `>>` instead.
Solutions
- Replace `>>>` with the signed `>>` when operands are BigInt and the values fit the signed range.
- Convert operands to Numbers before `>>>` when the values fit in 32 bits: `Number(a) >>> Number(b)`.
- Restructure the algorithm to avoid unsigned shift on BigInt (e.g. mask with BigInt: `a & 0xFFFFFFFFn` then `>>`).
- Keep BigInt values out of hashing code paths; do those computations in Java helpers instead.
Example fix
// before * eval hash = bigIntValue >>> 16 // after * eval hash = bigIntValue >> 16n // or, if it fits 32 bits: * eval hash = Number(bigIntValue) >>> 16
Defensive patterns
Strategy: type-guard
Validate before calling
if (typeof a === 'bigint' || typeof b === 'bigint') { /* use >> or mask */ } else { result = a >>> b; } Type guard
function usesBigInt(a, b) { return typeof a === 'bigint' || typeof b === 'bigint'; } Prevention
- Ban >>> in BigInt code paths; use >> plus masking instead.
- Convert to Number when values fit 32 bits before unsigned shifts.
- Review ported hashing code for unsigned-shift idioms.
- Keep BigInt isolated to big-number logic; hash with plain numbers.
When it happens
Trigger: Evaluating `a >>> b` in the embedded JS engine where `a` or `b` is a BigInt/BigInteger (isBigIntOp true), regardless of whether the other operand is a plain number.
Common situations: Porting bit-manipulation JavaScript that uses `>>>` for hashing/parsing into Karate JS while feeding BigInt values (e.g. from Java bridges or `BigInt()` conversions).
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Cannot convert undefined to a BigInt
- Cannot convert object to a BigInt
- Cannot convert a BigInt to a number
- BigInt.prototype method called on non-BigInt
- Cannot mix BigInt and other types, use explicit conversions
AI-assisted analysis of karatelabs/karate@a22eb90246 (2026-09-12).
Data as JSON: /api/errors/5a7a29b75ab0cf6c.
Report an issue: GitHub.
Appendix: source
Thrown at karate-js/src/main/java/io/karatelabs/js/Terms.java:723
Number lhs = toNumericOperand(lhsObject, context);
if (context != null && context.isError()) return UNDEFINED;
Number rhs = toNumericOperand(rhsObject, context);
if (context != null && context.isError()) return UNDEFINED;
if (isBigIntOp(lhs, rhs)) {
requireBothBigInt(lhs, rhs, "<<");
return narrowBigInt(((BigInteger) lhs).shiftLeft(((BigInteger) rhs).intValueExact()));
}
return lhs.intValue() << rhs.intValue();
}
static Object bitShiftRightUnsigned(Object lhsObject, Object rhsObject, CoreContext context) {
Number lhs = toNumericOperand(lhsObject, context);
if (context != null && context.isError()) return UNDEFINED;
Number rhs = toNumericOperand(rhsObject, context);
if (context != null && context.isError()) return UNDEFINED;
if (isBigIntOp(lhs, rhs)) {
// spec: unsigned right shift on BigInt always TypeError, even when both operands are BigInt
throw JsErrorException.typeError("BigInts have no unsigned right shift, use >> instead");
}
return narrow((lhs.intValue() & 0xFFFFFFFFL) >>> rhs.intValue());
}
static Object bitNot(Object value, CoreContext context) {
Number number = toNumericOperand(value, context);
if (context != null && context.isError()) return UNDEFINED;
if (number instanceof BigInteger bi) {
return narrowBigInt(bi.not());
}
return ~number.intValue();
}
static Object mul(Object lhsObject, Object rhsObject, CoreContext context) {
Number lhs = toNumericOperand(lhsObject, context);
if (context != null && context.isError()) return UNDEFINED;
Number rhs = toNumericOperand(rhsObject, context);
if (context != null && context.isError()) return UNDEFINED;View on GitHub (pinned to a22eb90246)