Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix Issue 12574 - [ICE](statement.c, line 713) with reduce with wrong…
… tuple arity Make `TemplateInstance::semanticTiargs` reentrant against semantic errors.
- Loading branch information
Showing
4 changed files
with
88 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
TEST_OUTPUT: | ||
--- | ||
fail_compilation/ice12574.d(41): Error: tuple index 2 exceeds length 2 | ||
fail_compilation/ice12574.d(41): Error: tuple index 2 exceeds 2 | ||
fail_compilation/ice12574.d(54): Error: template instance ice12574.reduce!("a", "a").reduce!(Tuple!(int, int, int)) error instantiating | ||
--- | ||
*/ | ||
|
||
struct Tuple(T...) | ||
{ | ||
alias Types = T; | ||
T field; | ||
alias field this; | ||
} | ||
Tuple!A tuple(A...)(A args) { return typeof(return)(args); } | ||
|
||
template binaryFun(alias fun) | ||
{ | ||
static if (is(typeof(fun) : string)) | ||
{ | ||
auto binaryFun(ElementType1, ElementType2)(auto ref ElementType1 __a, auto ref ElementType2 __b) | ||
{ | ||
mixin("alias "~"a"~" = __a ;"); | ||
mixin("alias "~"b"~" = __b ;"); | ||
return mixin(fun); | ||
} | ||
} | ||
else | ||
{ | ||
alias binaryFun = fun; | ||
} | ||
} | ||
|
||
template reduce(fun...) | ||
{ | ||
auto reduce(Seed)(Seed result) | ||
{ | ||
foreach (i, Unused; Seed.Types) | ||
{ | ||
result[i] = binaryFun!(fun[i])(1, 1); // here | ||
} | ||
return result; | ||
} | ||
} | ||
|
||
int foo(int value) | ||
{ | ||
return value; | ||
} | ||
|
||
void main() | ||
{ | ||
reduce!("a", "a")(tuple(1, 1, 1)); | ||
} |