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>
This commit is contained in:
Amjad Ben Hedhili
2022-09-27 11:47:45 +01:00
committed by GitHub
parent d755c02b02
commit 98a717dda9

View File

@@ -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