mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
fixing static class properties that are implicit objects.
This commit is contained in:
parent
72847b9b26
commit
08e1101c1f
4 changed files with 124 additions and 109 deletions
|
@ -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: [
|
||||
|
|
218
lib/parser.js
218
lib/parser.js
File diff suppressed because one or more lines are too long
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue