fixing static class properties that are implicit objects.

This commit is contained in:
Jeremy Ashkenas 2010-09-18 22:25:45 -04:00
parent 72847b9b26
commit 08e1101c1f
4 changed files with 124 additions and 109 deletions

View File

@ -241,6 +241,8 @@
return $1;
}), o("ThisProperty : Expression", function() {
return new AssignNode(new ValueNode($1), $3, 'this');
}), o("ThisProperty : INDENT Expression OUTDENT", function() {
return new AssignNode(new ValueNode($1), $4, 'this');
})
],
ClassBody: [

File diff suppressed because one or more lines are too long

View File

@ -286,6 +286,7 @@ grammar =
ClassAssign: [
o "AssignObj", -> $1
o "ThisProperty : Expression", -> new AssignNode new ValueNode($1), $3, 'this'
o "ThisProperty : INDENT Expression OUTDENT", -> new AssignNode new ValueNode($1), $4, 'this'
]
# A list of assignments to a class.

View File

@ -245,4 +245,14 @@ obj =
method: -> 'value'
instance = new obj.klass
ok instance.method() is 'value'
ok instance.method() is 'value'
# Implicit objects as static properties.
class Static
@static:
one: 1
two: 2
ok Static.static.one is 1
ok Static.static.two is 2