mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-29 01:14:41 +00:00
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() =
# ...
```
(cherry picked from commit 0bd4d80238)
25 lines
433 B
Nim
25 lines
433 B
Nim
discard """
|
|
outputsub: '''Error: expression expected, but found '[EOF]' 45'''
|
|
"""
|
|
|
|
# feature request #1473
|
|
import macros
|
|
|
|
macro test(text: string): untyped =
|
|
try:
|
|
result = parseExpr(text.strVal)
|
|
except ValueError:
|
|
result = newLit getCurrentExceptionMsg()
|
|
|
|
const
|
|
valid = 45
|
|
a = test("foo&&")
|
|
b = test("valid")
|
|
c = test("\"") # bug #2504
|
|
|
|
echo a, " ", b
|
|
|
|
static:
|
|
# Issue #9918
|
|
discard parseStmt("echo(1+1);")
|