summary refs log tree commit diff stats
path: root/tests/macros/ttryparseexpr.nim
diff options
context:
space:
mode:
authorJake Leahy <jake@leahy.dev>2023-12-17 19:01:00 +1100
committerGitHub <noreply@github.com>2023-12-17 09:01:00 +0100
commit0bd4d802383518cfbb43fa02375602abdfb6114f (patch)
treea36c99cfc70ee1208f8264ddc82fee045c3725a2 /tests/macros/ttryparseexpr.nim
parent9648d97a8dab053067e2c50b2f5b0d7c3650d5e3 (diff)
downloadNim-0bd4d802383518cfbb43fa02375602abdfb6114f.tar.gz
Allow `parseAll` to parse statements separated by semicolons (#23088)
Fixes the second issue listed in #9918.

Fixed by replacing the logic used in `parseAll` with just a continious
loop to `complexOrSimpleStmt` like what the [normal parser
does](https://github.com/nim-lang/Nim/blob/devel/compiler/passes.nim#L143-L146).
`complexOrSimpleStmt` [guarantees
progress](https://github.com/nim-lang/Nim/blob/devel/compiler/parser.nim#L2541)
so we don't need to check progress ourselves.

Also allows `nimpretty` to parse more valid Nim code such as 
```nim
proc foo(); # Would complain about indention here
# ...
proc foo() = 
  # ...
```
Diffstat (limited to 'tests/macros/ttryparseexpr.nim')
-rw-r--r--tests/macros/ttryparseexpr.nim4
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/macros/ttryparseexpr.nim b/tests/macros/ttryparseexpr.nim
index fc0ee61d0..e6e9e9880 100644
--- a/tests/macros/ttryparseexpr.nim
+++ b/tests/macros/ttryparseexpr.nim
@@ -18,3 +18,7 @@ const
   c = test("\"") # bug #2504
 
 echo a, " ", b
+
+static:
+  # Issue #9918
+  discard parseStmt("echo(1+1);")