summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorSaem Ghani <saemghani+github@gmail.com>2021-02-22 03:27:23 -0800
committerGitHub <noreply@github.com>2021-02-22 12:27:23 +0100
commit2aba116bbc8c1a595e49c8a703f2b8aecd7e8eda (patch)
tree3ffe6b7f4997248524be7d0b90681bdf9a264ac1 /compiler
parent05711d95e0481ad0c48c1a6f1704e629290c5e30 (diff)
downloadNim-2aba116bbc8c1a595e49c8a703f2b8aecd7e8eda.tar.gz
when statements branches exit early (#17143)
When statement branches exit early outside of nimvm. In nimvm it seems that all
sides of the branches must be evaluated as the code gen happens at a later
stage, this remains intact.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/semexprs.nim1
1 files changed, 1 insertions, 0 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index c1365a83d..e32e08d4b 100644
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -2364,6 +2364,7 @@ proc semWhen(c: PContext, n: PNode, semCheck = true): PNode =
           discard
         elif e.intVal != 0 and result == nil:
           setResult(it[1])
+          return # we're not in nimvm and we already have a result
     of nkElse, nkElseExpr:
       checkSonsLen(it, 1, c.config)
       if result == nil or whenNimvm: