diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim index ed2452241e..9bd107995d 100644 --- a/compiler/jsgen.nim +++ b/compiler/jsgen.nim @@ -1532,7 +1532,7 @@ proc genSymAddr(p: PProc, n: PNode, typ: PType, r: var TCompRes) = r.res = s.loc.snippet r.address = "" r.typ = etyNone - of skVar, skLet, skResult: + of skVar, skLet, skResult, skTemp, skForVar: r.kind = resExpr let jsType = mapType(p): if typ.isNil: diff --git a/tests/js/test2.nim b/tests/js/test2.nim index fa857ccc5c..c4cb2a25d3 100644 --- a/tests/js/test2.nim +++ b/tests/js/test2.nim @@ -4,7 +4,12 @@ js 3.14 7 1 -21550 --21550''' +-21550 +none(TT) +() +destroyed +destroyed +''' """ # This file tests the JavaScript generator @@ -56,3 +61,15 @@ proc foo09() = const y = 86400 echo (x - (y - 1)) div y # Still gives `-21551` foo09() + +import std/options + +type TT = object + +proc `=destroy`(x: TT) = echo "destroyed" + +func test1: Option[TT] = discard +func test2: TT = discard + +echo test1() # Crash in JS backend, not crash in C backend +echo test2() # Not crash