From 80b0748d75fe70febd89f02cf419e1644f67350d Mon Sep 17 00:00:00 2001 From: flywind <43030857+xflywind@users.noreply.github.com> Date: Sat, 31 Oct 2020 19:06:13 +0800 Subject: [PATCH] fix #15651 (#15800) * fix * minor --- compiler/jsgen.nim | 1 + tests/js/treprinifexpr.nim | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 tests/js/treprinifexpr.nim diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim index 766e6a80d4..cd14f1cf9d 100644 --- a/compiler/jsgen.nim +++ b/compiler/jsgen.nim @@ -1927,6 +1927,7 @@ proc genRepr(p: PProc, n: PNode, r: var TCompRes) = genReprAux(p, n, r, "reprJSONStringify") else: genReprAux(p, n, r, "reprAny", genTypeInfo(p, t)) + r.kind = resExpr proc genOf(p: PProc, n: PNode, r: var TCompRes) = var x: TCompRes diff --git a/tests/js/treprinifexpr.nim b/tests/js/treprinifexpr.nim new file mode 100644 index 0000000000..09ded18b9e --- /dev/null +++ b/tests/js/treprinifexpr.nim @@ -0,0 +1,18 @@ +type + Enum = enum A + +let + enumVal = A + tmp = if true: $enumVal else: $enumVal + +let + intVal = 12 + tmp2 = if true: repr(intVal) else: $enumVal + +let + strVal = "123" + tmp3 = if true: repr(strVal) else: $strVal + +let + floatVal = 12.4 + tmp4 = if true: repr(floatVal) else: $floatVal \ No newline at end of file