adding paren wrappers for property accesses directly on object literals

This commit is contained in:
Jeremy Ashkenas
2010-02-15 19:13:08 -05:00
parent 639be2ff09
commit 63c2b2bc64
3 changed files with 7 additions and 0 deletions

View File

@@ -320,6 +320,9 @@
only = del(o, 'only_first'); only = del(o, 'only_first');
props = only ? this.properties.slice(0, this.properties.length - 1) : this.properties; props = only ? this.properties.slice(0, this.properties.length - 1) : this.properties;
baseline = this.base.compile(o); baseline = this.base.compile(o);
if (this.base instanceof ObjectNode && this.has_properties()) {
baseline = '(' + baseline + ')';
}
parts = [baseline]; parts = [baseline];
__a = props; __a = props;
for (__b = 0; __b < __a.length; __b++) { for (__b = 0; __b < __a.length; __b++) {

View File

@@ -257,6 +257,7 @@ ValueNode: exports.ValueNode: inherit Node, {
only: del(o, 'only_first') only: del(o, 'only_first')
props: if only then @properties[0...@properties.length - 1] else @properties props: if only then @properties[0...@properties.length - 1] else @properties
baseline: @base.compile o baseline: @base.compile o
baseline: '(' + baseline + ')' if @base instanceof ObjectNode and @has_properties()
parts: [baseline] parts: [baseline]
for prop in props for prop in props

View File

@@ -37,6 +37,9 @@ money$: 'dollars'
puts money$ is 'dollars' puts money$ is 'dollars'
puts {a: (num) -> num is 10 }.a 10
bob: { bob: {
name: 'Bob' name: 'Bob'
greet: (salutation) -> greet: (salutation) ->