fixes #1385: property access on parenthesized number literals

This commit is contained in:
Michael Ficarra 2011-05-24 16:27:07 -04:00
parent 19520d8d35
commit c8845643e5
3 changed files with 7 additions and 3 deletions

View File

@ -502,8 +502,8 @@
this.base.front = this.front;
props = this.properties;
code = this.base.compile(o, props.length ? LEVEL_ACCESS : null);
if (props[0] instanceof Access && this.isSimpleNumber()) {
code = "(" + code + ")";
if ((this.base instanceof Parens || props.length) && SIMPLENUM.test(code)) {
code = "" + code + ".";
}
for (_i = 0, _len = props.length; _i < _len; _i++) {
prop = props[_i];

View File

@ -402,7 +402,7 @@ exports.Value = class Value extends Base
@base.front = @front
props = @properties
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

View File

@ -32,11 +32,15 @@ value = 0.0 + -.25 - -.75 + 0.0
ok value is 0.5
#764: Numbers should be indexable
eq Number::toString, 4['toString']
eq Number::toString, 4.2['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, .42.toString
eq Number::toString, (4).toString
test '#1168: leading floating point suppresses newline', ->
eq 1, do ->