Skip to content

Commit e26a182

Browse files
authored
fixes #1202; if expression containing procedure calls doesn't compile (#1208)
fixes #1202
1 parent 7b9e460 commit e26a182

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/nimony/controlflow.nim

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,13 @@ proc trUseExpr(c: var ControlFlow; n: var Cursor) =
299299

300300
proc trStmtOrExpr(c: var ControlFlow; n: var Cursor; tar: var Target) =
301301
if tar.m != IsIgnored:
302+
var aa = Target(m: IsEmpty)
303+
# it may be a `ExprX` so we generate statements before `AsgnS`
304+
trExpr c, n, aa
302305
c.dest.addParLe(AsgnS, n.info)
303306
assert tar.t.len > 0
304307
c.dest.add tar
305-
trUseExpr c, n
308+
c.dest.add aa
306309
c.dest.addParRi()
307310
else:
308311
trStmt c, n
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
proc foo = discard
2+
3+
var x = if true:
4+
1
5+
else:
6+
foo()
7+
2

0 commit comments

Comments
 (0)