From 6395a7cf151412e7925b3f9d2d57aa3adbd04686 Mon Sep 17 00:00:00 2001 From: hlaaftana <10591326+metagn@users.noreply.github.com> Date: Wed, 20 Jul 2022 12:41:43 +0300 Subject: [PATCH] add changelog entry, fix double not nil bug --- changelog.md | 5 +++++ compiler/parser.nim | 4 +--- tests/parser/tdoublenotnil.nim | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 tests/parser/tdoublenotnil.nim diff --git a/changelog.md b/changelog.md index a9170ffacae88..529dff562c8a6 100644 --- a/changelog.md +++ b/changelog.md @@ -142,6 +142,11 @@ need to convert to `string`. On the JS backend, this is translated directly to a `switch` statement. +- `foo a = b` now means `foo(a = b)` rather than `foo(a) = b`. This is consistent + with the existing behavior of `foo a, b = c` meaning `foo(a, b = c)`. + This decision was made with the assumption that the old syntax was used rarely; + if your code used the old syntax, please be aware of this change. + ## Compiler changes - The `gc` switch has been renamed to `mm` ("memory management") in order to reflect the diff --git a/compiler/parser.nim b/compiler/parser.nim index 6e630880b83c7..fd88b03e74a13 100644 --- a/compiler/parser.nim +++ b/compiler/parser.nim @@ -1393,9 +1393,7 @@ proc parseTypeDefValue(p: var Parser): PNode = result = parseTypeClass(p) else: result = simpleExpr(p, pmTypeDef) - if p.tok.tokType == tkNot: - result = binaryNot(p, result) - else: + if p.tok.tokType != tkNot: if result.kind == nkCommand: var isFirstParam = false while p.tok.tokType == tkComma: diff --git a/tests/parser/tdoublenotnil.nim b/tests/parser/tdoublenotnil.nim new file mode 100644 index 0000000000000..c61008c548c85 --- /dev/null +++ b/tests/parser/tdoublenotnil.nim @@ -0,0 +1,3 @@ +when false: + type Foo = Bar not nil not nil #[tt.Error + ^ invalid indentation]#