mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-04-11 03:00:13 -04:00
FIXES #397: Can't use @variable in switch in instance method
This commit is contained in:
@@ -1744,7 +1744,7 @@
|
|||||||
IfNode = function(condition, body, tags) {
|
IfNode = function(condition, body, tags) {
|
||||||
IfNode.__superClass__.constructor.call(this, {
|
IfNode.__superClass__.constructor.call(this, {
|
||||||
name: 'IfNode',
|
name: 'IfNode',
|
||||||
children: ['condition', 'body', 'else_body', 'assigner']
|
children: ['condition', 'switch_subject', 'body', 'else_body', 'assigner']
|
||||||
});
|
});
|
||||||
this.condition = condition;
|
this.condition = condition;
|
||||||
this.body = body;
|
this.body = body;
|
||||||
|
|||||||
@@ -1206,7 +1206,7 @@ exports.ForNode: class ForNode extends BaseNode
|
|||||||
exports.IfNode: class IfNode extends BaseNode
|
exports.IfNode: class IfNode extends BaseNode
|
||||||
|
|
||||||
constructor: (condition, body, tags) ->
|
constructor: (condition, body, tags) ->
|
||||||
super {name: 'IfNode', children: ['condition', 'body', 'else_body', 'assigner']}
|
super {name: 'IfNode', children: ['condition', 'switch_subject', 'body', 'else_body', 'assigner']}
|
||||||
@condition: condition
|
@condition: condition
|
||||||
@body: body
|
@body: body
|
||||||
@else_body: null
|
@else_body: null
|
||||||
|
|||||||
@@ -26,3 +26,15 @@ class Hive.Bee extends Hive
|
|||||||
|
|
||||||
maya: new Hive.Bee('Maya')
|
maya: new Hive.Bee('Maya')
|
||||||
ok maya.name is 'Maya'
|
ok maya.name is 'Maya'
|
||||||
|
|
||||||
|
|
||||||
|
# Issue #397: Can't use @variable in switch in instance method
|
||||||
|
obj: {
|
||||||
|
value: true
|
||||||
|
fn: ->
|
||||||
|
result: switch @value
|
||||||
|
when true then 'Hello!'
|
||||||
|
else 'Bye!'
|
||||||
|
}
|
||||||
|
|
||||||
|
ok obj.fn() is 'Hello!'
|
||||||
|
|||||||
Reference in New Issue
Block a user