summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAmjad Ben Hedhili <amjadhedhili@outlook.com>2022-09-27 11:47:45 +0100
committerGitHub <noreply@github.com>2022-09-27 12:47:45 +0200
commit98a717dda92ff45dc14818815ddc53764339066b (patch)
treed8096b0a420696ba7190c0c13b19280f126d4b48
parentd755c02b02011b06ba8584a645c2c71cfc746987 (diff)
downloadNim-98a717dda92ff45dc14818815ddc53764339066b.tar.gz
allow more simple expressions in js (#20270)
* make it match ccgexprs.nim `isSimpleExpr`
* x in {1, 2}
* r[].x and r.x when r is ref type
* float(x)

Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
-rw-r--r--compiler/jsgen.nim4
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim
index cf2a570e3..dc58efb82 100644
--- a/compiler/jsgen.nim
+++ b/compiler/jsgen.nim
@@ -330,7 +330,9 @@ proc isSimpleExpr(p: PProc; n: PNode): bool =
   # calls all the way down --> can stay expression based
   case n.kind
   of nkCallKinds, nkBracketExpr, nkDotExpr, nkPar, nkTupleConstr,
-    nkObjConstr, nkBracket, nkCurly:
+    nkObjConstr, nkBracket, nkCurly,
+    nkDerefExpr, nkHiddenDeref, nkAddr, nkHiddenAddr,
+    nkConv, nkHiddenStdConv, nkHiddenSubConv:
     for c in n:
       if not p.isSimpleExpr(c): return false
     result = true