Skip to content

Commit d7b4db0

Browse files
committed
TEST: Add test for scoping issue
See #2146
1 parent aea2a6f commit d7b4db0

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

integration_tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ RUN(NAME expr_16 LABELS cpython c)
423423
RUN(NAME expr_17 LABELS cpython llvm c)
424424
RUN(NAME expr_18 FAIL LABELS cpython llvm c)
425425
RUN(NAME expr_19 LABELS cpython llvm c)
426+
RUN(NAME expr_20 LABELS cpython llvm c)
426427

427428
RUN(NAME expr_01u LABELS cpython llvm c NOFAST)
428429
RUN(NAME expr_02u LABELS cpython llvm c NOFAST)

integration_tests/expr_20.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from lpython import i16, i32
2+
3+
def f():
4+
i: i32 = 5
5+
print(i16(i % 1023))
6+
7+
def u16(x: i16) -> i32:
8+
if x >= i16(0):
9+
return i32(x)
10+
else:
11+
return i32(x) + 65536
12+
13+
f()
14+
print(u16(i16(10)), u16(i16(-10)))
15+
assert(u16(i16(10)) == 10)
16+
assert(u16(i16(-10)) == 65526)

0 commit comments

Comments
 (0)