diff --git a/src/func.c b/src/func.c index 93654fd65bc0..da4382ec93a6 100644 --- a/src/func.c +++ b/src/func.c @@ -1467,6 +1467,12 @@ void FuncDeclaration::semantic3(Scope *sc) } if (inv) { + #if 1 + // Workaround for bugzilla 13394: For the correct mangling, + // run attribute inference on inv if needed. + inv->functionSemantic(); + #endif + //e = new DsymbolExp(Loc(), inv); //e = new CallExp(Loc(), e); //e = e->semantic(sc2); @@ -1485,6 +1491,13 @@ void FuncDeclaration::semantic3(Scope *sc) } else { + #if 1 + // Workaround for bugzilla 13394: For the correct mangling, + // run attribute inference on inv if needed. + if (ad->isStructDeclaration() && ad->inv) + ad->inv->functionSemantic(); + #endif + // Call invariant virtually Expression *v = new ThisExp(Loc()); v->type = vthis->type; @@ -1519,6 +1532,12 @@ void FuncDeclaration::semantic3(Scope *sc) } if (inv) { + #if 1 + // Workaround for bugzilla 13394: For the correct mangling, + // run attribute inference on inv if needed. + inv->functionSemantic(); + #endif + //e = new DsymbolExp(Loc(), inv); //e = new CallExp(Loc(), e); //e = e->semantic(sc2); @@ -1536,6 +1555,13 @@ void FuncDeclaration::semantic3(Scope *sc) } else { + #if 1 + // Workaround for bugzilla 13394: For the correct mangling, + // run attribute inference on inv if needed. + if (ad->isStructDeclaration() && ad->inv) + ad->inv->functionSemantic(); + #endif + // Call invariant virtually Expression *v = new ThisExp(Loc()); v->type = vthis->type; diff --git a/test/runnable/imports/link13394a.d b/test/runnable/imports/link13394a.d new file mode 100644 index 000000000000..57b4422a8f6d --- /dev/null +++ b/test/runnable/imports/link13394a.d @@ -0,0 +1,24 @@ +module imports.link13394a; + +class A +{ + this() { } +} + +class Btpl(T) : T +{ + this()() { } + + invariant() {} +} + +alias B = Btpl!A; + +struct Stpl() +{ + void func()() {} + + invariant() {} +} + +alias S = Stpl!(); diff --git a/test/runnable/link13394.d b/test/runnable/link13394.d new file mode 100644 index 000000000000..aea86862a659 --- /dev/null +++ b/test/runnable/link13394.d @@ -0,0 +1,13 @@ +// COMPILE_SEPARATELY +// EXTRA_SOURCES: imports/link13394a.d + +module link13394; +import imports.link13394a; + +void main() +{ + auto b = new B(); + + auto s = S(); + s.func(); +}