diff options
-rw-r--r-- | compiler/jsgen.nim | 1 | ||||
-rw-r--r-- | tests/js/tbyvar.nim | 10 |
2 files changed, 11 insertions, 0 deletions
diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim index 70398a241..f802a7263 100644 --- a/compiler/jsgen.nim +++ b/compiler/jsgen.nim @@ -1173,6 +1173,7 @@ proc genDeref(p: PProc, n: PNode, r: var TCompRes) = else: var a: TCompRes gen(p, n.sons[0], a) + r.kind = resExpr if a.typ == etyBaseIndex: r.res = "$1[$2]" % [a.address, a.res] elif n.sons[0].kind == nkCall: diff --git a/tests/js/tbyvar.nim b/tests/js/tbyvar.nim index 40aebd13b..f974049b9 100644 --- a/tests/js/tbyvar.nim +++ b/tests/js/tbyvar.nim @@ -49,3 +49,13 @@ block: # Test get addr of byvar return value let a = addr t["hi"] a[] = 10 doAssert(t["hi"] == 10) + +block: # Test var arg inside case expression. #5244 + proc foo(a: var string) = + a = case a + of "a": "error" + of "b": "error" + else: a + var a = "ok" + foo(a) + doAssert(a == "ok") |