Index: Microsoft.JScript/Statement.cs =================================================================== --- Microsoft.JScript/Statement.cs (revision 53350) +++ Microsoft.JScript/Statement.cs (working copy) @@ -211,7 +211,8 @@ internal class Return : AST { - internal AST expression; + internal AST expression; + private bool exp_returns_void = false; public event NotVoidReturnEventHandler not_void_return; internal Return (Location location) @@ -246,6 +247,17 @@ if (!InFunction) throw new Exception ("error JS1018: 'return' statement outside of function"); if (expression != null) { + if (expression is Expression) { + AST ast = ((Expression) expression).Last; + if (ast is Call) { + Call call = (Call) ast; + if (call.member_exp is Identifier) { + object obj = env.Get (String.Empty, ((Identifier) call.member_exp).name); + if (obj is Function) + exp_returns_void = ((Function) obj).HandleReturnType == typeof (void); + } + } + } OnNotVoidReturn (null); return expression.Resolve (env); } else @@ -261,6 +273,10 @@ if (expression != null) { expression.Emit (ec); loc = ig.DeclareLocal (typeof (object)); + + if (exp_returns_void) + ig.Emit (OpCodes.Ldnull); + ig.Emit (OpCodes.Stloc, loc); } Index: Microsoft.JScript/ast.cs =================================================================== --- Microsoft.JScript/ast.cs (revision 53350) +++ Microsoft.JScript/ast.cs (working copy) @@ -197,7 +197,7 @@ not_void_return = true; } - protected Type HandleReturnType { + internal Type HandleReturnType { get { Type ret_type; if (not_void_return)