Merge pull request #4734 from kierdavis/toplevel-defer-error
Display error message if defer statement is used at top level
This commit is contained in:
commit
51a4b82d37
1 changed files with 2 additions and 0 deletions
|
|
@ -443,6 +443,8 @@ proc isImportSystemStmt(n: PNode): bool =
|
||||||
else: discard
|
else: discard
|
||||||
|
|
||||||
proc semStmtAndGenerateGenerics(c: PContext, n: PNode): PNode =
|
proc semStmtAndGenerateGenerics(c: PContext, n: PNode): PNode =
|
||||||
|
if n.kind == nkDefer:
|
||||||
|
localError(n.info, "defer statement not supported at top level")
|
||||||
if c.topStmts == 0 and not isImportSystemStmt(n):
|
if c.topStmts == 0 and not isImportSystemStmt(n):
|
||||||
if sfSystemModule notin c.module.flags and
|
if sfSystemModule notin c.module.flags and
|
||||||
n.kind notin {nkEmpty, nkCommentStmt}:
|
n.kind notin {nkEmpty, nkCommentStmt}:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue