summary refs log tree commit diff stats
path: root/tests/distinct/tnil.nim
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2022-08-24 01:27:20 +0800
committerGitHub <noreply@github.com>2022-08-23 19:27:20 +0200
commit1182216381cdd17b75e16133ce2c79084dd3d3f9 (patch)
tree85e3c4edea3889dee2125188acc7703dc4072947 /tests/distinct/tnil.nim
parent7d7886b729b40872cc2ad7c0c370179b6b39df0c (diff)
downloadNim-1182216381cdd17b75e16133ce2c79084dd3d3f9.tar.gz
remove a special case in sigmatch; distinct pointer types no longer match `nil` type (#20251)
* remove a special case in sigmatch; distinct pointer types no longer match `nil` type

* add tests

* fixes tests

* Update changelog.md

Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
Diffstat (limited to 'tests/distinct/tnil.nim')
-rw-r--r--tests/distinct/tnil.nim18
1 files changed, 5 insertions, 13 deletions
diff --git a/tests/distinct/tnil.nim b/tests/distinct/tnil.nim
index 5bdb97f37..b54c07432 100644
--- a/tests/distinct/tnil.nim
+++ b/tests/distinct/tnil.nim
@@ -1,29 +1,21 @@
-discard """
-output: '''
-1
-0
-0
-'''
-"""
 {.experimental: "notnil".}
 type
   MyPointer = distinct pointer
   MyString = distinct string
   MyInt = distinct int
 
-proc foo(a: MyPointer) =
+proc foo(a: MyPointer): int =
   # workaround a Windows 'repr' difference:
-  echo cast[int](a)
+  cast[int](a)
 
-foo(cast[MyPointer](1))
-foo(cast[MyPointer](nil))
-foo(nil)
+doAssert foo(cast[MyPointer](1)) == 1
+doAssert foo(cast[MyPointer](nil)) == 0
+doAssert foo(MyPointer(nil)) == 0
 
 var p: MyPointer
 p = cast[MyPointer](1)
 p = cast[MyPointer](nil)
 p = nil.MyPointer
-p = nil
 
 var i: MyInt
 i = 1.MyInt