summary refs log tree commit diff stats
path: root/tests/int/t1.nim
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2024-08-11 19:10:04 +0800
committerGitHub <noreply@github.com>2024-08-11 13:10:04 +0200
commitf0e1eef65ed08fb153b88615f07ea0fd91e4c258 (patch)
tree4b580b25b54f31d9fc89ef7347f0d6eb4e23e731 /tests/int/t1.nim
parent49544692598812a8306b8f9b4b437eac32ca804e (diff)
downloadNim-f0e1eef65ed08fb153b88615f07ea0fd91e4c258.tar.gz
fixes #14522 #22085 #12700 #23132; no range check for uints (#23930)
fixes #14522
fixes #22085
fixes #12700
fixes #23132
closes https://github.com/nim-lang/Nim/pull/22343 (succeeded by this PR)
completes https://github.com/nim-lang/RFCs/issues/175

follow up https://github.com/nim-lang/Nim/pull/12688
Diffstat (limited to 'tests/int/t1.nim')
-rw-r--r--tests/int/t1.nim25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/int/t1.nim b/tests/int/t1.nim
index 36402da07..d08f5f29b 100644
--- a/tests/int/t1.nim
+++ b/tests/int/t1.nim
@@ -1,3 +1,7 @@
+discard """
+  targets: "c cpp"
+"""
+
 doAssert typeOf(1.int64 + 1.int) is int64
 doAssert typeOf(1.uint64 + 1.uint) is uint64
 doAssert int64 is SomeNumber
@@ -12,3 +16,24 @@ doAssert typeOf(myInt16 + myInt) is int   # of type `int`
 doAssert typeOf(myInt16 + 2i32) is int32  # of type `int32`
 doAssert int32 isnot int64
 doAssert int32 isnot int
+
+block:
+  # bug #22085
+  const
+    x = uint32(uint64.high) # vm error
+    u = uint64.high
+    v = uint32(u) # vm error
+
+  let
+    z = uint64.high
+    y = uint32(z)  # runtime ok
+
+  let
+    w = uint32(uint64.high)  # semfold error
+
+  doAssert x == w
+  doAssert v == y
+
+  # bug #14522
+  doAssert 0xFF000000_00000000.uint64 == 18374686479671623680'u64
+