Display error message if defer statement is used at top level

This commit is contained in:
Kier Davis
2016-09-07 16:56:49 +01:00
parent 08a6f3fc67
commit f0db17e2cd

View File

@@ -443,6 +443,8 @@ proc isImportSystemStmt(n: PNode): bool =
else: discard
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 sfSystemModule notin c.module.flags and
n.kind notin {nkEmpty, nkCommentStmt}: