Fix defer not not-working at top level (#10191)
This commit is contained in:
parent
15773c455a
commit
e77dd683eb
4 changed files with 4 additions and 13 deletions
|
|
@ -2624,6 +2624,8 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
|
|||
of nkStaticStmt:
|
||||
result = semStaticStmt(c, n)
|
||||
of nkDefer:
|
||||
if c.currentScope == c.topLevelScope:
|
||||
localError(c.config, n.info, "defer statement not supported at top level")
|
||||
n.sons[0] = semExpr(c, n.sons[0])
|
||||
if not n.sons[0].typ.isEmptyType and not implicitlyDiscardable(n.sons[0]):
|
||||
localError(c.config, n.info, "'defer' takes a 'void' expression")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue