parent
ee0a470294
commit
42ac50e988
4 changed files with 12 additions and 1 deletions
|
|
@ -2393,6 +2393,10 @@ proc parseAll(p: var Parser): PNode =
|
|||
if p.tok.indent != 0:
|
||||
parMessage(p, errInvalidIndentation)
|
||||
|
||||
proc checkFirstLineIndentation*(p: var Parser) =
|
||||
if p.tok.indent != 0 and p.tok.strongSpaceA > 0:
|
||||
parMessage(p, errInvalidIndentation)
|
||||
|
||||
proc parseTopLevelStmt(p: var Parser): PNode =
|
||||
## Implements an iterator which, when called repeatedly, returns the next
|
||||
## top-level statement or emptyNode if end of stream.
|
||||
|
|
|
|||
|
|
@ -150,6 +150,7 @@ proc processModule*(graph: ModuleGraph; module: PSym; idgen: IdGenerator;
|
|||
processImplicits graph, graph.config.implicitImports, nkImportStmt, a, module
|
||||
processImplicits graph, graph.config.implicitIncludes, nkIncludeStmt, a, module
|
||||
|
||||
checkFirstLineIndentation(p)
|
||||
while true:
|
||||
if graph.stopCompile(): break
|
||||
var n = parseTopLevelStmt(p)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import
|
|||
when defined(nimPreviewSlimSystem):
|
||||
import std/[syncio, assertions]
|
||||
|
||||
export Parser, parseAll, parseTopLevelStmt, closeParser
|
||||
export Parser, parseAll, parseTopLevelStmt, checkFirstLineIndentation, closeParser
|
||||
|
||||
type
|
||||
FilterKind = enum
|
||||
|
|
|
|||
6
tests/parser/t19662.nim
Normal file
6
tests/parser/t19662.nim
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
var i: int # bug #19662
|
||||
echo i
|
||||
|
||||
discard """
|
||||
errormsg: "invalid indentation"
|
||||
"""
|
||||
Loading…
Add table
Add a link
Reference in a new issue