diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2016-09-07 21:58:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-07 21:58:03 +0200 |
commit | 51a4b82d374cff2072698b86b43a292d52c64335 (patch) | |
tree | fac00e526bc1d7b9479c6122ba174b18a1939ebd | |
parent | 08a6f3fc67f1bac78c47a241c94f936d7fbd5108 (diff) | |
parent | f0db17e2cd76bf18ff1859451157cd4a065c9037 (diff) | |
download | Nim-51a4b82d374cff2072698b86b43a292d52c64335.tar.gz |
Merge pull request #4734 from kierdavis/toplevel-defer-error
Display error message if defer statement is used at top level
-rw-r--r-- | compiler/sem.nim | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/compiler/sem.nim b/compiler/sem.nim index ccbd665e9..b713dbbbb 100644 --- a/compiler/sem.nim +++ b/compiler/sem.nim @@ -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}: |