Skip to content

Commit 61afa79

Browse files
committed
reduce parentheses around %% operator
Back when I wrote 4cbbd93, I didn't know about `o.level`. Now I do.
1 parent dcbbcb5 commit 61afa79

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

lib/ast.js

Lines changed: 6 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ast.ls

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,9 +1527,11 @@ class exports.Binary extends Node
15271527

15281528
compileMod: (o) ->
15291529
ref = o.scope.temporary!
1530-
code = [sn(this, "((("), (@first.compile o), sn(this, ") % ("), sn(this, ref, " = "), (@second.compile o), sn(this, ") + ", ref, ") % ", ref, ")")]
1530+
code = [sn(this, "(("), (@first.compile o), sn(this, ") % ("), sn(this, ref, " = "), (@second.compile o), sn(this, ") + ", ref, ") % ", ref)]
15311531
o.scope.free ref
1532-
sn(null, ...code)
1532+
if o.level < LEVEL_OP + PREC\%
1533+
then sn(null, ...code)
1534+
else sn(null, "(", ...code, ")")
15331535

15341536
compilePartial: (o) ->
15351537
vit = Var \it

0 commit comments

Comments
 (0)