Skip to content

Commit

Permalink
fix Issue 13158 - "void has no value" in std.variant.Algebraic (affec…
Browse files Browse the repository at this point in the history
…ts D:YAML)
  • Loading branch information
9rnsr committed Jul 21, 2014
1 parent 59b0000 commit 75ffb63
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 19 deletions.
39 changes: 20 additions & 19 deletions src/template.c
Expand Up @@ -6340,6 +6340,26 @@ void TemplateInstance::semantic(Scope *sc, Expressions *fargs)
tryExpandMembers(sc2);

semanticRun = PASSsemanticdone;

/* ConditionalDeclaration may introduce eponymous declaration,
* so we should find it once again after semantic.
*/
if (members->dim)
{
Dsymbol *s;
if (Dsymbol::oneMembers(members, &s, tempdecl->ident) && s)
{
if (!aliasdecl || aliasdecl != s)
{
//printf("s->kind = '%s'\n", s->kind());
//s->print();
//printf("'%s', '%s'\n", s->ident->toChars(), tempdecl->ident->toChars());
//printf("setting aliasdecl 2\n");
aliasdecl = s;
}
}
}

if (global.errors != errorsave)
goto Laftersemantic;

Expand Down Expand Up @@ -6369,25 +6389,6 @@ void TemplateInstance::semantic(Scope *sc, Expressions *fargs)
goto Laftersemantic;
}

/* ConditionalDeclaration may introduce eponymous declaration,
* so we should find it once again after semantic.
*/
if (members->dim)
{
Dsymbol *s;
if (Dsymbol::oneMembers(members, &s, tempdecl->ident) && s)
{
if (!aliasdecl || aliasdecl != s)
{
//printf("s->kind = '%s'\n", s->kind());
//s->print();
//printf("'%s', '%s'\n", s->ident->toChars(), tempdecl->ident->toChars());
//printf("setting aliasdecl 2\n");
aliasdecl = s;
}
}
}

/* The problem is when to parse the initializer for a variable.
* Perhaps VarDeclaration::semantic() should do it like it does
* for initializers inside a function.
Expand Down
29 changes: 29 additions & 0 deletions test/runnable/template9.d
Expand Up @@ -3699,6 +3699,35 @@ void test13127a()
foo(a, a);
}

/******************************************/
// 13159

template maxSize13159(T...)
{
static if (T.length == 1)
{
enum size_t maxSize13159 = T[0].sizeof;
}
else
{
enum size_t maxSize13159 =
T[0].sizeof >= maxSize13159!(T[1 .. $])
? T[0].sizeof
: maxSize13159!(T[1 .. $]);
}
}

struct Node13159
{
struct Pair
{
Node13159 value;
}

//alias Algebraic!(Node[], int) Value;
enum n = maxSize13159!(Node13159[], int);
}

/******************************************/

int main()
Expand Down

0 comments on commit 75ffb63

Please sign in to comment.