From 71b36df0989b28a0d036c3288f17fd14888d938a Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Mon, 15 May 2023 14:15:06 -0400 Subject: [PATCH] add tests for more types --- tests/parser/features/test_assignment.py | 30 ++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/parser/features/test_assignment.py b/tests/parser/features/test_assignment.py index e0003d66a8..0dd63a0d09 100644 --- a/tests/parser/features/test_assignment.py +++ b/tests/parser/features/test_assignment.py @@ -285,3 +285,33 @@ def bug(xs: uint256[2]) -> uint256[2]: c = get_contract(code) assert c.bug([1, 2]) == [2, 1] + + +def test_assign_rhs_lhs_overlap_dynarray(get_contract): + # GH issue 2418, generalize to dynarrays + code = """ +@external +def bug(xs: DynArray[uint256, 2]) -> DynArray[uint256, 2]: + ys: DynArray[uint256, 2] = xs + ys = [ys[1], ys[0]] + return ys + """ + c = get_contract(code) + assert c.bug([1, 2]) == [2, 1] + + +def test_assign_rhs_lhs_overlap_struct(get_contract): + # GH issue 2418, generalize to structs + code = """ +struct Point: + x: uint256 + y: uint256 + +@external +def bug(p: Point) -> Point: + t: Point = p + t = Point({x: t.y, y: t.x}) + return t + """ + c = get_contract(code) + assert c.bug((1, 2)) == (2, 1)