public override bool Resolve (EmitContext ec)
{
- expr = expr.ResolveStatement (ec);
+ if (expr != null)
+ expr = expr.ResolveStatement (ec);
return expr != null;
}
return false;
}
+ if (ec.InIterator) {
+ Report.Error (1622, loc, "Cannot return a value from iterators. Use the yield return " +
+ "statement to return a value, or yield break to end the iteration");
+ return false;
+ }
+
Expr = Expr.Resolve (ec);
if (Expr == null)
return false;
if (variables == null)
variables = new Hashtable ();
+ Block cur = this;
+ while (cur != null && cur.Implicit)
+ cur = cur.Parent;
+
LocalInfo vi = GetLocalInfo (name);
if (vi != null) {
- if (vi.Block != this)
+ Block var = vi.Block;
+ while (var != null && var.Implicit)
+ var = var.Parent;
+ if (var != cur)
Report.Error (136, l, "A local variable named `" + name + "' " +
"cannot be declared in this scope since it would " +
"give a different meaning to `" + name + "', which " +
variables.Add (name, vi);
// Mark 'name' as "used by a child block" in every surrounding block
- Block cur = this;
- while (cur != null && cur.Implicit)
- cur = cur.Parent;
if (cur != null)
for (Block par = cur.Parent; par != null; par = par.Parent)
par.AddChildVariableName (name);
par = pars.GetParameterByName (name, out idx);
if (par != null){
- ParameterReference pr;
-
- pr = new ParameterReference (pars, this, idx, name, loc);
- return pr;
+ return new ParameterReference (pars, this, idx, name, loc);
}
}
b = b.Parent;