Skip to content

Commit

Permalink
allow more simple expressions in js (#20270)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
AmjadHD and Varriount committed Sep 27, 2022
1 parent d755c02 commit 98a717d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion compiler/jsgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 98a717d

Please sign in to comment.