Permalink
Browse files

Merge pull request #1451 from 9rnsr/fix9273

Issue 9273 & 9284 - DMD segfaults with templated ctors
  • Loading branch information...
2 parents 7da048b + 1c8305d commit a899e6147517f78f6d23064ca764533b789b8579 @donc donc committed Jan 9, 2013
Showing with 65 additions and 0 deletions.
  1. +4 −0 src/expression.c
  2. +24 −0 test/fail_compilation/ice9273a.d
  3. +15 −0 test/fail_compilation/ice9273b.d
  4. +22 −0 test/fail_compilation/ice9284.d
View
@@ -8290,6 +8290,8 @@ Expression *CallExp::semantic(Scope *sc)
}
f = resolveFuncCall(sc, loc, cd->baseClass->ctor, NULL, NULL, arguments, 0);
+ if (!f)
+ return new ErrorExp();
accessCheck(loc, sc, NULL, f);
checkDeprecated(sc, f);
#if DMDV2
@@ -8332,6 +8334,8 @@ Expression *CallExp::semantic(Scope *sc)
}
f = resolveFuncCall(sc, loc, cd->ctor, NULL, NULL, arguments, 0);
+ if (!f)
+ return new ErrorExp();
checkDeprecated(sc, f);
#if DMDV2
checkPurity(sc, f);
@@ -0,0 +1,24 @@
+/*
+TEST_OUTPUT:
+---
+fail_compilation/ice9273a.d(19): Error: constructor ice9273a.C.__ctor!().this no match for implicit super() call in constructor
+fail_compilation/ice9273a.d(23): Error: template instance ice9273a.C.__ctor!() error instantiating
+---
+*/
+
+template CtorMixin()
+{
+ this(T)() {}
+}
+class B
+{
+ mixin CtorMixin!();
+}
+class C : B
+{
+ this()() {}
+}
+void main()
+{
+ auto c = new C();
+}
@@ -0,0 +1,15 @@
+/*
+TEST_OUTPUT:
+---
+fail_compilation/ice9273b.d(14): Error: constructor ice9273b.B.this no match for implicit super() call in constructor
+---
+*/
+
+class A
+{
+ this(T)() {}
+}
+class B : A
+{
+ this() {}
+}
@@ -0,0 +1,22 @@
+/*
+TEST_OUTPUT:
+---
+fail_compilation/ice9284.d(15): Error: template ice9284.C.__ctor does not match any function template declaration. Candidates are:
+fail_compilation/ice9284.d(13): ice9284.C.__ctor()(string)
+fail_compilation/ice9284.d(15): Error: template ice9284.C.__ctor()(string) cannot deduce template function from argument types !()(int)
+fail_compilation/ice9284.d(21): Error: template instance ice9284.C.__ctor!() error instantiating
+---
+*/
+
+class C
+{
+ this()(string)
+ {
+ this(10);
+ // delegating to a constructor which not exists.
+ }
+}
+void main()
+{
+ new C("hello");
+}

0 comments on commit a899e61

Please sign in to comment.