Skip to content

Commit ca87d9d

Browse files
committed
Integer#<< error should be RangeError now and not NoMemoryError with the new specs
1 parent a0c2b53 commit ca87d9d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/main/java/org/truffleruby/core/numeric/IntegerNodes.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,14 +1206,14 @@ protected int leftShift(long a, long b,
12061206
if (zeroProfile.profile(a == 0L)) {
12071207
return 0;
12081208
} else {
1209-
throw new RaiseException(getContext(), coreExceptions().noMemoryError(this, null));
1209+
throw shiftWidthTooBig();
12101210
}
12111211
}
12121212

12131213
@Specialization(guards = "b > MAX_INT")
12141214
protected int leftShift(RubyBignum a, long b) {
12151215
// We raise a NoMemoryError like MRI; JRuby would raise a coercion error.
1216-
throw new RaiseException(getContext(), coreExceptions().noMemoryError(this, null));
1216+
throw shiftWidthTooBig();
12171217
}
12181218

12191219
@Specialization(guards = "isPositive(b)")
@@ -1222,14 +1222,18 @@ protected int leftShift(long a, RubyBignum b,
12221222
if (zeroProfile.profile(a == 0L)) {
12231223
return 0;
12241224
} else {
1225-
throw new RaiseException(getContext(), coreExceptions().noMemoryError(this, null));
1225+
throw shiftWidthTooBig();
12261226
}
12271227
}
12281228

12291229
@Specialization(guards = "isPositive(b)")
12301230
protected int leftShift(RubyBignum a, RubyBignum b) {
12311231
// We raise a NoMemoryError like MRI; JRuby would raise a coercion error.
1232-
throw new RaiseException(getContext(), coreExceptions().noMemoryError(this, null));
1232+
throw shiftWidthTooBig();
1233+
}
1234+
1235+
private RaiseException shiftWidthTooBig() {
1236+
return new RaiseException(getContext(), coreExceptions().rangeError("shift width too big", this));
12331237
}
12341238

12351239
// b < 0, delegate to a >> -b

0 commit comments

Comments
 (0)