Bug 26840

Summary: InternalErrorException on specifying Optional attribute
Product: [Mono] Compilers Reporter: Leonid Shalupov <leonid>
Component: C#Assignee: Marek Safar <masafa>
Status: RESOLVED FIXED    
Severity: normal CC: mono-bugs+mono
Priority: ---    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Tags: Is this bug a regression?: ---
Last known good build:
Attachments: Repro

Description Leonid Shalupov 2015-02-08 08:29:33 UTC
"mcs -unsafe b.cs" fails exception. See attached file for source.

Unhandled Exception:
Mono.CSharp.InternalErrorException: b.cs(4,11): test ---> Mono.CSharp.InternalErrorException: b.cs(6,29): test.MainClass ---> Mono.CSharp.InternalErrorException: b.cs(13,25): test.MainClass.FooDelegate ---> System.InvalidCastException: Cannot cast from source type to destination type.
  at Mono.CSharp.Parameter.ResolveDefaultValue (Mono.CSharp.ResolveContext rc) [0x00000] in <filename unknown>:0
  at Mono.CSharp.ParametersCompiled.ResolveDefaultValues (Mono.CSharp.MemberCore m) [0x00000] in <filename unknown>:0
  at Mono.CSharp.Delegate.PrepareEmit () [0x00000] in <filename unknown>:0
  at Mono.CSharp.TypeContainer.PrepareEmit () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at Mono.CSharp.TypeContainer.PrepareEmit () [0x00000] in <filename unknown>:0
  at Mono.CSharp.TypeDefinition.PrepareEmit () [0x00000] in <filename unknown>:0
  at Mono.CSharp.TypeContainer.PrepareEmit () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at Mono.CSharp.TypeContainer.PrepareEmit () [0x00000] in <filename unknown>:0
  at Mono.CSharp.TypeContainer.PrepareEmit () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at Mono.CSharp.TypeContainer.PrepareEmit () [0x00000] in <filename unknown>:0
  at Mono.CSharp.CompilationSourceFile.PrepareEmit () [0x00000] in <filename unknown>:0
  at Mono.CSharp.ModuleContainer.EmitContainer () [0x00000] in <filename unknown>:0
  at Mono.CSharp.AssemblyDefinition.Emit () [0x00000] in <filename unknown>:0
  at Mono.CSharp.AssemblyDefinitionStatic.Emit () [0x00000] in <filename unknown>:0
  at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0
  at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: Mono.CSharp.InternalErrorException: b.cs(4,11): test ---> Mono.CSharp.InternalErrorException: b.cs(6,29): test.MainClass ---> Mono.CSharp.InternalErrorException: b.cs(13,25): test.MainClass.FooDelegate ---> System.InvalidCastException: Cannot cast from source type to destination type.
  at Mono.CSharp.Parameter.ResolveDefaultValue (Mono.CSharp.ResolveContext rc) [0x00000] in <filename unknown>:0
  at Mono.CSharp.ParametersCompiled.ResolveDefaultValues (Mono.CSharp.MemberCore m) [0x00000] in <filename unknown>:0
  at Mono.CSharp.Delegate.PrepareEmit () [0x00000] in <filename unknown>:0
  at Mono.CSharp.TypeContainer.PrepareEmit () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at Mono.CSharp.TypeContainer.PrepareEmit () [0x00000] in <filename unknown>:0
  at Mono.CSharp.TypeDefinition.PrepareEmit () [0x00000] in <filename unknown>:0
  at Mono.CSharp.TypeContainer.PrepareEmit () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at Mono.CSharp.TypeContainer.PrepareEmit () [0x00000] in <filename unknown>:0
  at Mono.CSharp.TypeContainer.PrepareEmit () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at Mono.CSharp.TypeContainer.PrepareEmit () [0x00000] in <filename unknown>:0
  at Mono.CSharp.CompilationSourceFile.PrepareEmit () [0x00000] in <filename unknown>:0
  at Mono.CSharp.ModuleContainer.EmitContainer () [0x00000] in <filename unknown>:0
  at Mono.CSharp.AssemblyDefinition.Emit () [0x00000] in <filename unknown>:0
  at Mono.CSharp.AssemblyDefinitionStatic.Emit () [0x00000] in <filename unknown>:0
  at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0
  at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0
Comment 1 Leonid Shalupov 2015-02-08 08:30:21 UTC
Created attachment 9697 [details]
Repro
Comment 2 Marek Safar 2015-02-10 02:50:11 UTC
Fixed in master