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
commit 98a717dda9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -330,7 +330,9 @@ proc isSimpleExpr(p: PProc; n: PNode): bool =
# calls all the way down --> can stay expression based # calls all the way down --> can stay expression based
case n.kind case n.kind
of nkCallKinds, nkBracketExpr, nkDotExpr, nkPar, nkTupleConstr, of nkCallKinds, nkBracketExpr, nkDotExpr, nkPar, nkTupleConstr,
nkObjConstr, nkBracket, nkCurly: nkObjConstr, nkBracket, nkCurly,
nkDerefExpr, nkHiddenDeref, nkAddr, nkHiddenAddr,
nkConv, nkHiddenStdConv, nkHiddenSubConv:
for c in n: for c in n:
if not p.isSimpleExpr(c): return false if not p.isSimpleExpr(c): return false
result = true result = true