Skip to content

Instantly share code, notes, and snippets.

@marek-safar
Created November 27, 2013 08:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marek-safar/7672515 to your computer and use it in GitHub Desktop.
Save marek-safar/7672515 to your computer and use it in GitHub Desktop.
diff --git a/mcs/mcs/method.cs b/mcs/mcs/method.cs
index ca6ef5d..4416c00 100644
--- a/mcs/mcs/method.cs
+++ b/mcs/mcs/method.cs
@@ -1466,7 +1466,7 @@ namespace Mono.CSharp {
} else {
//
// It is legal to have "this" initializers that take no arguments
- // in structs, they are just no-ops.
+ // in structs
//
// struct D { public D (int a) : this () {}
//
@@ -1487,9 +1487,14 @@ namespace Mono.CSharp {
public override void Emit (EmitContext ec)
{
- // It can be null for static initializers
- if (base_ctor == null)
+ //
+ // It can be null for struct initializers
+ //
+ if (base_ctor == null) {
+ ec.Emit (OpCodes.Ldarg_0);
+ ec.Emit (OpCodes.Initobj, type);
return;
+ }
var call = new CallEmitter ();
call.InstanceExpression = new CompilerGeneratedThis (type, loc);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment