fixes #1385: property access on parenthesized number literals
This commit is contained in:
parent
19520d8d35
commit
c8845643e5
|
@ -502,8 +502,8 @@
|
||||||
this.base.front = this.front;
|
this.base.front = this.front;
|
||||||
props = this.properties;
|
props = this.properties;
|
||||||
code = this.base.compile(o, props.length ? LEVEL_ACCESS : null);
|
code = this.base.compile(o, props.length ? LEVEL_ACCESS : null);
|
||||||
if (props[0] instanceof Access && this.isSimpleNumber()) {
|
if ((this.base instanceof Parens || props.length) && SIMPLENUM.test(code)) {
|
||||||
code = "(" + code + ")";
|
code = "" + code + ".";
|
||||||
}
|
}
|
||||||
for (_i = 0, _len = props.length; _i < _len; _i++) {
|
for (_i = 0, _len = props.length; _i < _len; _i++) {
|
||||||
prop = props[_i];
|
prop = props[_i];
|
||||||
|
|
|
@ -402,7 +402,7 @@ exports.Value = class Value extends Base
|
||||||
@base.front = @front
|
@base.front = @front
|
||||||
props = @properties
|
props = @properties
|
||||||
code = @base.compile o, if props.length then LEVEL_ACCESS else null
|
code = @base.compile o, if props.length then LEVEL_ACCESS else null
|
||||||
code = "(#{code})" if props[0] instanceof Access and @isSimpleNumber()
|
code = "#{code}." if (@base instanceof Parens or props.length) and SIMPLENUM.test code
|
||||||
code += prop.compile o for prop in props
|
code += prop.compile o for prop in props
|
||||||
code
|
code
|
||||||
|
|
||||||
|
|
|
@ -32,11 +32,15 @@ value = 0.0 + -.25 - -.75 + 0.0
|
||||||
ok value is 0.5
|
ok value is 0.5
|
||||||
|
|
||||||
#764: Numbers should be indexable
|
#764: Numbers should be indexable
|
||||||
|
eq Number::toString, 4['toString']
|
||||||
eq Number::toString, 4.2['toString']
|
eq Number::toString, 4.2['toString']
|
||||||
eq Number::toString, .42['toString']
|
eq Number::toString, .42['toString']
|
||||||
|
eq Number::toString, (4)['toString']
|
||||||
|
|
||||||
|
eq Number::toString, 4.toString
|
||||||
eq Number::toString, 4.2.toString
|
eq Number::toString, 4.2.toString
|
||||||
eq Number::toString, .42.toString
|
eq Number::toString, .42.toString
|
||||||
|
eq Number::toString, (4).toString
|
||||||
|
|
||||||
test '#1168: leading floating point suppresses newline', ->
|
test '#1168: leading floating point suppresses newline', ->
|
||||||
eq 1, do ->
|
eq 1, do ->
|
||||||
|
|
Loading…
Reference in New Issue