fixes #9076
This commit is contained in:
parent
3d768738f8
commit
787687727a
3 changed files with 26 additions and 2 deletions
|
|
@ -1159,4 +1159,4 @@ proc genStmts(p: BProc, t: PNode) =
|
||||||
if isPush: pushInfoContext(p.config, t.info)
|
if isPush: pushInfoContext(p.config, t.info)
|
||||||
expr(p, t, a)
|
expr(p, t, a)
|
||||||
if isPush: popInfoContext(p.config)
|
if isPush: popInfoContext(p.config)
|
||||||
internalAssert p.config, a.k in {locNone, locTemp, locLocalVar}
|
internalAssert p.config, a.k in {locNone, locTemp, locLocalVar, locExpr}
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ const
|
||||||
skipForDiscardable = {nkIfStmt, nkIfExpr, nkCaseStmt, nkOfBranch,
|
skipForDiscardable = {nkIfStmt, nkIfExpr, nkCaseStmt, nkOfBranch,
|
||||||
nkElse, nkStmtListExpr, nkTryStmt, nkFinally, nkExceptBranch,
|
nkElse, nkStmtListExpr, nkTryStmt, nkFinally, nkExceptBranch,
|
||||||
nkElifBranch, nkElifExpr, nkElseExpr, nkBlockStmt, nkBlockExpr,
|
nkElifBranch, nkElifExpr, nkElseExpr, nkBlockStmt, nkBlockExpr,
|
||||||
nkHiddenStdConv}
|
nkHiddenStdConv, nkHiddenDeref}
|
||||||
|
|
||||||
proc implicitlyDiscardable(n: PNode): bool =
|
proc implicitlyDiscardable(n: PNode): bool =
|
||||||
var n = n
|
var n = n
|
||||||
|
|
@ -601,6 +601,8 @@ proc semForVars(c: PContext, n: PNode; flags: TExprFlags): PNode =
|
||||||
inc(c.p.nestedLoopCounter)
|
inc(c.p.nestedLoopCounter)
|
||||||
openScope(c)
|
openScope(c)
|
||||||
n.sons[length-1] = semExprBranch(c, n.sons[length-1], flags)
|
n.sons[length-1] = semExprBranch(c, n.sons[length-1], flags)
|
||||||
|
if efInTypeof notin flags:
|
||||||
|
discardCheck(c, n.sons[length-1], flags)
|
||||||
closeScope(c)
|
closeScope(c)
|
||||||
dec(c.p.nestedLoopCounter)
|
dec(c.p.nestedLoopCounter)
|
||||||
|
|
||||||
|
|
|
||||||
22
tests/discard/tneedsdiscard_in_for.nim
Normal file
22
tests/discard/tneedsdiscard_in_for.nim
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
discard """
|
||||||
|
line: 22
|
||||||
|
errormsg: '''expression 'premultiply(app.gradient[i])' is of type 'Rgba8' and has to be discarded'''
|
||||||
|
"""
|
||||||
|
|
||||||
|
# bug #9076
|
||||||
|
type
|
||||||
|
Rgba8 = object
|
||||||
|
|
||||||
|
proc premultiply*(c: var Rgba8): var Rgba8 =
|
||||||
|
discard
|
||||||
|
|
||||||
|
type
|
||||||
|
App = ref object
|
||||||
|
gradient: seq[Rgba8]
|
||||||
|
|
||||||
|
method onDraw(app: App) {.base.} =
|
||||||
|
var
|
||||||
|
width = 100'f64
|
||||||
|
|
||||||
|
for i in 0..<width.int:
|
||||||
|
app.gradient[i].premultiply()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue