Skip to content

Commit 0a6aeef

Browse files
valfflydell
authored andcommitted
Fix //= operator (#4410)
1 parent ebb56e0 commit 0a6aeef

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

lib/coffee-script/nodes.js

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

src/nodes.coffee

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2083,7 +2083,8 @@ exports.Op = class Op extends Base
20832083

20842084
compileFloorDivision: (o) ->
20852085
floor = new Value new IdentifierLiteral('Math'), [new Access new PropertyName 'floor']
2086-
div = new Op '/', @first, @second
2086+
second = if @second.isComplex() then new Parens @second else @second
2087+
div = new Op '/', @first, second
20872088
new Call(floor, [div]).compileToFragments o
20882089

20892090
compileModulo: (o) ->

test/operators.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ test "floor division operator", ->
330330

331331
test "floor division operator compound assignment", ->
332332
a = 7
333-
a //= 2
333+
a //= 1 + 1
334334
eq 3, a
335335

336336
test "modulo operator", ->

0 commit comments

Comments
 (0)