diff --git a/src/dtemplate.d b/src/dtemplate.d index 6eab49b50f6f..02709c73d0fc 100644 --- a/src/dtemplate.d +++ b/src/dtemplate.d @@ -6352,6 +6352,7 @@ public: // Elide codegen because this is really speculative. return false; } + /* Even when this is reached to the codegen pass, * a non-root nested template should not generate code, * due to avoid ODR violation. @@ -6359,11 +6360,20 @@ public: if (enclosing && enclosing.inNonRoot()) { if (tinst) - return tinst.needsCodegen(); + { + auto r = tinst.needsCodegen(); + minst = tinst.minst; // cache result + return r; + } if (tnext) - return tnext.needsCodegen(); + { + auto r = tnext.needsCodegen(); + minst = tnext.minst; // cache result + return r; + } return false; } + /* The issue is that if the importee is compiled with a different -debug * setting than the importer, the importer may believe it exists * in the compiled importee when it does not, when the instantiation diff --git a/test/runnable/ice15138.d b/test/runnable/ice15138.d new file mode 100644 index 000000000000..14d6bfb6020a --- /dev/null +++ b/test/runnable/ice15138.d @@ -0,0 +1,11 @@ +// EXTRA_SOURCES: imports/ice15138a.d +// PERMUTE_ARGS: -unittest -inline +// COMPILE_SEPARATELY + +import imports.ice15138a; + +void main() +{ + JSONValue v; + v.get!JSONValue; +} diff --git a/test/runnable/imports/ice15138a.d b/test/runnable/imports/ice15138a.d new file mode 100644 index 000000000000..5f72044123cf --- /dev/null +++ b/test/runnable/imports/ice15138a.d @@ -0,0 +1,28 @@ +module imports.ice15138a; + +alias AliasSeq(TL...) = TL; + +alias FieldNameTuple(T...) = AliasSeq!(); + +struct TaggedAlgebraic(U) +{ + alias X = FieldNameTuple!(U.tupleof); +} + +void get(T, U)(TaggedAlgebraic!U ta) {} + +union PayloadUnion +{ + int dummy; +} + +struct JSONValue +{ + alias Payload = TaggedAlgebraic!PayloadUnion; + + void get(T)() + { + Payload payload; + .get!T(payload); + } +}