Skip to content

Commit 7097f9b

Browse files
committed
[GR-12234] Add specialization for SetItemScalarNode
PullRequest: graalpython/251
2 parents 776e8b3 + b250a4b commit 7097f9b

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

graalpython/com.oracle.graal.python.test/src/tests/test_array.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,14 @@ def test_add():
8585
else:
8686
assert False
8787

88+
89+
def test_add_int_to_long_storage():
90+
x = [2147483648, 1]
91+
x[0] = 42 # should not raise
92+
assert x[0] == 42
93+
94+
def test_add_int_to_long_array():
95+
from array import array
96+
y = array('l', [1, 2])
97+
y[0] = 42 # should not raise
98+
assert y[0] == 42

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,11 @@ protected void doLong(LongSequenceStorage storage, int idx, long value) {
847847
storage.setLongItemNormalized(idx, value);
848848
}
849849

850+
@Specialization
851+
protected void doLong(LongSequenceStorage storage, int idx, int value) {
852+
storage.setLongItemNormalized(idx, value);
853+
}
854+
850855
@Specialization(guards = "!value.isNative()")
851856
protected void doLong(LongSequenceStorage storage, int idx, PInt value) {
852857
try {

0 commit comments

Comments
 (0)