more intuitive behaviour for 'discardable' in expression bodies
This commit is contained in:
parent
af441e607f
commit
f8af7ed6b4
6 changed files with 99 additions and 22 deletions
|
|
@ -1146,10 +1146,9 @@ proc semProcBody(c: PContext, n: PNode): PNode =
|
|||
# ``result``:
|
||||
if result.kind == nkSym and result.sym == c.p.resultSym:
|
||||
nil
|
||||
elif result.kind == nkNilLit or ImplicitlyDiscardable(result):
|
||||
# intended semantic: if it's 'discardable' and the context allows for it,
|
||||
# discard it. This is bad for chaining but nicer for C wrappers.
|
||||
# ambiguous :-(
|
||||
elif result.kind == nkNilLit:
|
||||
# or ImplicitlyDiscardable(result):
|
||||
# new semantic: 'result = x' triggers the void context
|
||||
result.typ = nil
|
||||
elif result.kind == nkStmtListExpr and result.typ.kind == tyNil:
|
||||
# to keep backwards compatibility bodies like:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue