summary refs log tree commit diff stats
path: root/tests/notnil
diff options
context:
space:
mode:
authormetagn <metagngn@gmail.com>2023-06-12 07:22:50 +0300
committerGitHub <noreply@github.com>2023-06-12 06:22:50 +0200
commite0ad71a912361d994b1d7b052d0153f7f5528a63 (patch)
treea9db339caee4998910e53fa72a1cd1b8e96b1fe6 /tests/notnil
parent7b1c448744f9b29a41d205f102fb2b4e7f735d88 (diff)
downloadNim-e0ad71a912361d994b1d7b052d0153f7f5528a63.tar.gz
make binary `not` not parse complex expressions on right side (#22078)
* binary `not` only parses simple expressions

fixes #16324

* switch to primary
Diffstat (limited to 'tests/notnil')
-rw-r--r--tests/notnil/tparse.nim18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/notnil/tparse.nim b/tests/notnil/tparse.nim
new file mode 100644
index 000000000..5c938ff04
--- /dev/null
+++ b/tests/notnil/tparse.nim
@@ -0,0 +1,18 @@
+# issue #16324
+
+{.push experimental: "notnil".}
+
+block:
+  type Foo = ref object
+    value: int
+    
+  proc newFoo1(): Foo not nil =               # This compiles
+    return Foo(value: 1)
+    
+  proc newFoo2(): Foo not nil {.inline.} =    # This does not
+    return Foo(value: 1)
+
+  doAssert newFoo1().value == 1
+  doAssert newFoo2().value == 1
+
+{.pop.}