Skip to content

Commit

Permalink
Merge pull request #5164 from 9rnsr/fix15138
Browse files Browse the repository at this point in the history
[REG2.068.2] Issue 15138 - ICE with basic use of stdx.data.json
  • Loading branch information
MartinNowak committed Oct 6, 2015
2 parents 44959a1 + f223530 commit e13c2bc
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/dtemplate.d
Expand Up @@ -6352,18 +6352,28 @@ 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.
*/
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
Expand Down
11 changes: 11 additions & 0 deletions 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;
}
28 changes: 28 additions & 0 deletions 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);
}
}

0 comments on commit e13c2bc

Please sign in to comment.