mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
Fix //= operator (#4410)
This commit is contained in:
parent
ebb56e08ca
commit
0a6aeef0c9
3 changed files with 6 additions and 4 deletions
|
@ -3115,9 +3115,10 @@
|
|||
};
|
||||
|
||||
Op.prototype.compileFloorDivision = function(o) {
|
||||
var div, floor;
|
||||
var div, floor, second;
|
||||
floor = new Value(new IdentifierLiteral('Math'), [new Access(new PropertyName('floor'))]);
|
||||
div = new Op('/', this.first, this.second);
|
||||
second = this.second.isComplex() ? new Parens(this.second) : this.second;
|
||||
div = new Op('/', this.first, second);
|
||||
return new Call(floor, [div]).compileToFragments(o);
|
||||
};
|
||||
|
||||
|
|
|
@ -2083,7 +2083,8 @@ exports.Op = class Op extends Base
|
|||
|
||||
compileFloorDivision: (o) ->
|
||||
floor = new Value new IdentifierLiteral('Math'), [new Access new PropertyName 'floor']
|
||||
div = new Op '/', @first, @second
|
||||
second = if @second.isComplex() then new Parens @second else @second
|
||||
div = new Op '/', @first, second
|
||||
new Call(floor, [div]).compileToFragments o
|
||||
|
||||
compileModulo: (o) ->
|
||||
|
|
|
@ -330,7 +330,7 @@ test "floor division operator", ->
|
|||
|
||||
test "floor division operator compound assignment", ->
|
||||
a = 7
|
||||
a //= 2
|
||||
a //= 1 + 1
|
||||
eq 3, a
|
||||
|
||||
test "modulo operator", ->
|
||||
|
|
Loading…
Add table
Reference in a new issue