Files
Nim/tests/macros/tfail_parse.nim
Jake Leahy db9d8003b0 Don't crash for invalid toplevel parseStmt/Expr calls (#23089)
This code will crash `check`/`nimsuggest` since the `ra` register is
uninitialised

```nim
import macros

static:
  discard parseExpr("'")
```
Now it assigns an empty node so that it has something

Testament changes were so I could properly write a test. It would pass
even with a segfault since it could find the error
2023-12-19 17:27:24 +01:00

16 lines
283 B
Nim

discard """
action: "reject"
cmd: "nim check $file"
errormsg: "expected expression, but got multiple statements [ValueError]"
file: "macros.nim"
"""
import macros
static:
discard parseStmt("'")
discard parseExpr("'")
discard parseExpr("""
proc foo()
proc foo() = discard
""")