check existence of this.context. Avoid build error

https://github.com/jashkenas/coffee-script/issues/1541

with thanks to analyst74 whose bug report made the fix trivial =)
This commit is contained in:
Mike Blume 2011-07-24 22:48:37 -07:00
parent e7854bec09
commit 178af9de56
2 changed files with 2 additions and 2 deletions

View File

@ -1144,7 +1144,7 @@
}
Assign.prototype.children = ['variable', 'value'];
Assign.prototype.isStatement = function(o) {
return (o != null ? o.level : void 0) === LEVEL_TOP && __indexOf.call(this.context, "?") >= 0;
return (o != null ? o.level : void 0) === LEVEL_TOP && (this.context != null) && __indexOf.call(this.context, "?") >= 0;
};
Assign.prototype.assigns = function(name) {
return this[this.context === 'object' ? 'value' : 'variable'].assigns(name);

View File

@ -917,7 +917,7 @@ exports.Assign = class Assign extends Base
children: ['variable', 'value']
isStatement: (o) ->
o?.level is LEVEL_TOP and "?" in @context
o?.level is LEVEL_TOP and @context? and "?" in @context
assigns: (name) ->
@[if @context is 'object' then 'value' else 'variable'].assigns name