Bug 22980 - compiler crashes on Func invocation
Summary: compiler crashes on Func invocation
Status: RESOLVED UPSTREAM
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: unspecified
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2014-09-14 10:52 UTC by JM
Modified: 2014-09-15 03:50 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED UPSTREAM

Description JM 2014-09-14 10:52:44 UTC
After creating a brand new c# console project, the following class crashes the compiler when I build. Removing func2 invocation makes the build pass. As func1 shows, using an explicit delegate type also works.


using System;
using System.Collections.Generic;


public class Bug {
    public delegate void FuncDelegate(string s);
    
    FuncDelegate func1;
    Func<string, Void> func2;
    
    void foo(string s) {
        Console.Write(s);
    }
    
    void Start () {
        func1 = foo;
        func2 = foo;
        func1("func1");
        func2("func2");  // Comment this out and the build will work.
    }
}






Building: console (Debug|x86)
Performing main compilation...
/Applications/Unity/MonoDevelop.app/Contents/Frameworks/Mono.framework/Versions/2.10.11/bin/dmcs /noconfig "/out:/Users/jm/workspace/console/console/bin/Debug/console.exe" "/r:/Applications/Unity/MonoDevelop.app/Contents/Frameworks/Mono.framework/Versions/2.10.11/lib/mono/4.0/System.dll" "/r:/Applications/Unity/MonoDevelop.app/Contents/Frameworks/Mono.framework/Versions/2.10.11/lib/mono/4.0/System.Core.dll" /nologo /warn:4 /debug:full /optimize- /codepage:utf8 /platform:x86 "/define:DEBUG"  /t:exe "/Users/jm/workspace/console/console/Main.cs" "/Users/jm/workspace/console/console/AssemblyInfo.cs" "/Users/jm/workspace/console/console/Bug.cs" 
Internal compiler error at /Users/jm/workspace/console/console/Bug.cs(15,10):: exception caught while emitting MethodBuilder [Bug::Start]


Unhandled Exception:
System.BadImageFormatException: VAR 1 (TResult) cannot be expanded with type 0x1
File name: '<no_image>'
  at (wrapper managed-to-native) System.Reflection.MonoMethodInfo:get_method_info (intptr,System.Reflection.MonoMethodInfo&)
  at System.Reflection.MonoMethodInfo.GetMethodInfo (IntPtr handle) [0x00000] in <filename unknown>:0 
  at System.Reflection.MonoMethodInfo.GetDeclaringType (IntPtr handle) [0x00000] in <filename unknown>:0 
  at System.Reflection.MonoMethod.get_DeclaringType () [0x00000] in <filename unknown>:0 
  at System.Reflection.Emit.ILGenerator.Emit (OpCode opcode, System.Reflection.MethodInfo meth) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.EmitContext.Emit (OpCode opcode, Mono.CSharp.MethodSpec method) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Invocation.EmitCall (Mono.CSharp.EmitContext ec, Mono.CSharp.Expression instance_expr, Mono.CSharp.MethodSpec method, Mono.CSharp.Arguments Arguments, Location loc, Boolean dup_args, Boolean omit_args) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Invocation.EmitCall (Mono.CSharp.EmitContext ec, Mono.CSharp.Expression instance_expr, Mono.CSharp.MethodSpec method, Mono.CSharp.Arguments Arguments, Location loc) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.DelegateInvocation.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.DelegateInvocation.EmitStatement (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.StatementExpression.DoEmit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Statement.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Block.DoEmit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Block.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.ExplicitBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.ToplevelBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.MethodData.Emit (Mono.CSharp.DeclSpace parent) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.MethodOrOperator.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Method.Emit () [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.BadImageFormatException: VAR 1 (TResult) cannot be expanded with type 0x1
File name: '<no_image>'
  at (wrapper managed-to-native) System.Reflection.MonoMethodInfo:get_method_info (intptr,System.Reflection.MonoMethodInfo&)
  at System.Reflection.MonoMethodInfo.GetMethodInfo (IntPtr handle) [0x00000] in <filename unknown>:0 
  at System.Reflection.MonoMethodInfo.GetDeclaringType (IntPtr handle) [0x00000] in <filename unknown>:0 
  at System.Reflection.MonoMethod.get_DeclaringType () [0x00000] in <filename unknown>:0 
  at System.Reflection.Emit.ILGenerator.Emit (OpCode opcode, System.Reflection.MethodInfo meth) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.EmitContext.Emit (OpCode opcode, Mono.CSharp.MethodSpec method) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Invocation.EmitCall (Mono.CSharp.EmitContext ec, Mono.CSharp.Expression instance_expr, Mono.CSharp.MethodSpec method, Mono.CSharp.Arguments Arguments, Location loc, Boolean dup_args, Boolean omit_args) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Invocation.EmitCall (Mono.CSharp.EmitContext ec, Mono.CSharp.Expression instance_expr, Mono.CSharp.MethodSpec method, Mono.CSharp.Arguments Arguments, Location loc) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.DelegateInvocation.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.DelegateInvocation.EmitStatement (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.StatementExpression.DoEmit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Statement.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Block.DoEmit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Block.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.ExplicitBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.ToplevelBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.MethodData.Emit (Mono.CSharp.DeclSpace parent) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.MethodOrOperator.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Method.Emit () [0x00000] in <filename unknown>:0 



Unhandled Exception:
System.BadImageFormatException: VAR 1 (TResult) cannot be expanded with type 0x1
File name: '<no_image>'
  at (wrapper managed-to-native) System.Reflection.MonoMethodInfo:get_method_info (intptr,System.Reflection.MonoMethodInfo&)
  at System.Reflection.MonoMethodInfo.GetMethodInfo (IntPtr handle) [0x00000] in <filename unknown>:0 
  at System.Reflection.MonoMethodInfo.GetDeclaringType (IntPtr handle) [0x00000] in <filename unknown>:0 
  at System.Reflection.MonoMethod.get_DeclaringType () [0x00000] in <filename unknown>:0 
  at System.Reflection.Emit.ILGenerator.Emit (OpCode opcode, System.Reflection.MethodInfo meth) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.EmitContext.Emit (OpCode opcode, Mono.CSharp.MethodSpec method) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Invocation.EmitCall (Mono.CSharp.EmitContext ec, Mono.CSharp.Expression instance_expr, Mono.CSharp.MethodSpec method, Mono.CSharp.Arguments Arguments, Location loc, Boolean dup_args, Boolean omit_args) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Invocation.EmitCall (Mono.CSharp.EmitContext ec, Mono.CSharp.Expression instance_expr, Mono.CSharp.MethodSpec method, Mono.CSharp.Arguments Arguments, Location loc) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.DelegateInvocation.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.DelegateInvocation.EmitStatement (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.StatementExpression.DoEmit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Statement.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Block.DoEmit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Block.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.ExplicitBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.ToplevelBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.MethodData.Emit (Mono.CSharp.DeclSpace parent) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.MethodOrOperator.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Method.Emit () [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.BadImageFormatException: VAR 1 (TResult) cannot be expanded with type 0x1
File name: '<no_image>'
  at (wrapper managed-to-native) System.Reflection.MonoMethodInfo:get_method_info (intptr,System.Reflection.MonoMethodInfo&)
  at System.Reflection.MonoMethodInfo.GetMethodInfo (IntPtr handle) [0x00000] in <filename unknown>:0 
  at System.Reflection.MonoMethodInfo.GetDeclaringType (IntPtr handle) [0x00000] in <filename unknown>:0 
  at System.Reflection.MonoMethod.get_DeclaringType () [0x00000] in <filename unknown>:0 
  at System.Reflection.Emit.ILGenerator.Emit (OpCode opcode, System.Reflection.MethodInfo meth) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.EmitContext.Emit (OpCode opcode, Mono.CSharp.MethodSpec method) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Invocation.EmitCall (Mono.CSharp.EmitContext ec, Mono.CSharp.Expression instance_expr, Mono.CSharp.MethodSpec method, Mono.CSharp.Arguments Arguments, Location loc, Boolean dup_args, Boolean omit_args) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Invocation.EmitCall (Mono.CSharp.EmitContext ec, Mono.CSharp.Expression instance_expr, Mono.CSharp.MethodSpec method, Mono.CSharp.Arguments Arguments, Location loc) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.DelegateInvocation.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.DelegateInvocation.EmitStatement (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.StatementExpression.DoEmit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Statement.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Block.DoEmit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Block.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.ExplicitBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.ToplevelBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.MethodData.Emit (Mono.CSharp.DeclSpace parent) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.MethodOrOperator.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Method.Emit () [0x00000] in <filename unknown>:0 
Build complete -- 1 error, 0 warnings

---------------------- Done ----------------------

Build: 1 error, 0 warnings








MonoDevelop-Unity
Version 4.0.1
Installation UUID: 39e23647-d4df-4bd9-8a41-83848c2d8422
Runtime:
	Mono 2.10.11 (mono-2-10/2baeee2 Wed Jan 16 16:40:16 EST 2013)
	GTK 2.24.14
	GTK# (2.12.0.0)
	Package version: 210110000

Build Information
Git revision: Release ID:
b7b113a37e4cc9ccfc633ff4bc31fa6f03ba2fe9
Build date: 2014-08-06 13:35:41+0000

Operating System
Mac OS X 10.9.4
Darwin jm 13.3.0 Darwin Kernel Version 13.3.0
    Tue Jun  3 21:27:35 PDT 2014
    root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64
Comment 1 Marek Safar 2014-09-15 03:50:43 UTC
This issue has been resolved resolved. Please use more recent version than 2.10.

(9,18): error CS0673: System.Void cannot be used from C#. Consider using `void'