Skip to content
Browse files

Fix #131 - detect use of 'this' within array initializers

  • Loading branch information...
1 parent 4cd0a4b commit 0a97a95bfeca92728d22ec2bbc016daff6a5720f @nikhilk committed Aug 27, 2012
View
15 src/Core/Compiler/ScriptModel/Expressions/LiteralExpression.cs
@@ -30,6 +30,21 @@ public LiteralExpression(TypeSymbol valueType, object value)
}
}
+ public override bool RequiresThisContext {
+ get {
+ Expression[] items = _value as Expression[];
+ if (items != null) {
+ foreach (Expression item in items) {
+ if (item.RequiresThisContext) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+ }
+
public object Value {
get {
return _value;
View
3 tests/TestCases/Expression/AnonymousMethods/Baseline.txt
@@ -45,6 +45,9 @@ test.Test.prototype = {
this._n++;
}));
}
+ var s2 = new test.SomeClass(ss.Delegate.create(this, function() {
+ var numbers = [ this._n ];
+ }));
},
doStuff: function(o, callback) {
View
4 tests/TestCases/Expression/AnonymousMethods/Code.cs
@@ -49,6 +49,10 @@ public class Test {
DoStuffStatic(o, delegate { });
DoStuffStatic(o, delegate { _n++; });
}
+
+ SomeClass s2 = new SomeClass(delegate {
+ int[] numbers = new int[] { _n };
+ });
}
public static void DoStuffStatic(object o, Foo callback) {

0 comments on commit 0a97a95

Please sign in to comment.
Something went wrong with that request. Please try again.