Skip to content

Commit

Permalink
fix Issue 15138 - ICE with basic use of stdx.data.json
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed Oct 5, 2015
1 parent 44959a1 commit f223530
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 f223530

Please sign in to comment.