Skip to content

Commit 449bf02

Browse files
committed
[GR-17548] The dict concat doesn't work.
1 parent 98dac2d commit 449bf02

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,4 +505,24 @@ def test_wrapped_string_contains2():
505505
def test_wrapped_string_get():
506506
a = 'test'
507507
dict = locals()
508-
assert dict['a']
508+
assert dict['a']
509+
510+
def test_concat():
511+
r = {**{}}
512+
assert len(r) == 0
513+
514+
r = {**{1:2}}
515+
assert len(r) == 1
516+
assert set(r.keys()) == {1}
517+
assert set(r.values()) == {2}
518+
519+
r = {**{}, 1:2}
520+
assert len(r) == 1
521+
assert set(r.keys()) == {1}
522+
assert set(r.values()) == {2}
523+
524+
r = {**{1:2}, 3:4, 6:8}
525+
assert len(r) == 3
526+
assert set(r.keys()) == {1, 3, 6}
527+
assert set(r.values()) == {2, 4, 8}
528+

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/generator/DictConcatNode.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,9 @@ private void addAllToDict(VirtualFrame frame, PDict dict, PDict other) {
8282
}
8383
HashingStorage dictStorage = dict.getDictStorage();
8484
for (Object key : other.keys()) {
85-
setItemNode.execute(frame, dictStorage, key, getItemNode.execute(frame, other.getDictStorage(), key));
85+
dictStorage = setItemNode.execute(frame, dictStorage, key, getItemNode.execute(frame, other.getDictStorage(), key));
8686
}
87+
dict.setDictStorage(dictStorage);
8788
}
8889

8990
private static PDict expectDict(Object first) {

0 commit comments

Comments
 (0)