-
-
Notifications
You must be signed in to change notification settings - Fork 608
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix Issue 15030 - ICE with recursive delegate, -unittest, and std.range
Refer the detailed explanation in `test/runnable/ice15030.d`.
- Loading branch information
Showing
5 changed files
with
152 additions
and
16 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| // REQUIRED_ARGS: -unittest -boundscheck=off | ||
| // PERMUTE_ARGS: | ||
| // EXTRA_SOURCES: imports/a15030.d imports/b15030.d | ||
|
|
||
| void main() {} | ||
|
|
||
| /+ | ||
| Compiler output with -v switch. | ||
| With 2.068.0: | ||
| -------- | ||
| code a | ||
| code b | ||
| function b.__unittestL5_2 | ||
| function b.__unittestL5_2.__lambda1 | ||
| function b.__unittestL5_2.__lambda1.__lambda2 | ||
| function b.__unittestL5_2.__lambda1.__lambda2.filter!((a) => a).filter!(int[]).filter | ||
| function b.__unittestL5_2.__lambda1.__lambda2.FilterResult!(__lambda2, int[]).FilterResult.this | ||
| function b.__unittestL5_2.__lambda1.__lambda2.FilterResult!(__lambda2, int[]).FilterResult.empty | ||
| function b.__unittestL5_2.__lambda1.__lambda2.FilterResult!(__lambda2, int[]).FilterResult.front | ||
| function b.__unittestL5_2.__lambda1.__lambda2.FilterResult!(__lambda2, int[]).FilterResult.popFront | ||
| function b.__unittestL5_2.__lambda1.__lambda2.FilterResult!(__lambda2, int[]).FilterResult.__xopEquals | ||
| function b.__unittestL5_2.__lambda1.__lambda2.FilterResult!(__lambda2, int[]).FilterResult.__xtoHash | ||
| function b.__unittestL5_2.__lambda1.__lambda2.__lambda2 | ||
| The nested functions '__lambda1', '__lambda2', and 'filter' are | ||
| (fortunately) generated from outer to inner. | ||
| With 2.068.1: | ||
| -------- | ||
| code a | ||
| function b.__unittestL5_2.__lambda1.__lambda2.filter!((a) => a).filter!(int[]).filter | ||
| function b.__unittestL5_2.__lambda1.__lambda2 | ||
| function b.__unittestL5_2.__lambda1.__lambda2.FilterResult!(__lambda2, int[]).FilterResult.this | ||
| function b.__unittestL5_2.__lambda1.__lambda2.FilterResult!(__lambda2, int[]).FilterResult.empty | ||
| function b.__unittestL5_2.__lambda1.__lambda2.FilterResult!(__lambda2, int[]).FilterResult.front | ||
| function b.__unittestL5_2.__lambda1.__lambda2.FilterResult!(__lambda2, int[]).FilterResult.popFront | ||
| function b.__unittestL5_2.__lambda1.__lambda2.FilterResult!(__lambda2, int[]).FilterResult.__xopEquals | ||
| function b.__unittestL5_2.__lambda1.__lambda2.FilterResult!(__lambda2, int[]).FilterResult.__xtoHash | ||
| code b | ||
| function b.__unittestL5_2 | ||
| function b.__unittestL5_2.__lambda1 | ||
| Assertion failure: '!v->csym' on line 1060 in file 'glue.c' | ||
| abnormal program termination | ||
| 'filer' is generated before its ancestor functions '__lambda1' and '__lambda2' - it's a bug. | ||
| Fixed (contains debug prints): | ||
| -------- | ||
| code a | ||
| b.__unittestL5_2.__lambda1.__lambda2.filter!((a) => a).filter!(int[]).filter @[algorithm.d(5)] | ||
| --> pushed to unittest @[b.d(5)] | ||
| function b.__unittestL5_2.__lambda1.__lambda2.FilterResult!(__lambda2, int[]).FilterResult.this | ||
| function b.__unittestL5_2.__lambda1.__lambda2.FilterResult!(__lambda2, int[]).FilterResult.empty | ||
| function b.__unittestL5_2.__lambda1.__lambda2.FilterResult!(__lambda2, int[]).FilterResult.front | ||
| function b.__unittestL5_2.__lambda1.__lambda2.FilterResult!(__lambda2, int[]).FilterResult.popFront | ||
| function b.__unittestL5_2.__lambda1.__lambda2.FilterResult!(__lambda2, int[]).FilterResult.__xopEquals | ||
| function b.__unittestL5_2.__lambda1.__lambda2.FilterResult!(__lambda2, int[]).FilterResult.__xtoHash | ||
| code b | ||
| function b.__unittestL5_2 | ||
| function b.__unittestL5_2.__lambda1 | ||
| function b.__unittestL5_2.__lambda1.__lambda2 | ||
| function b.__unittestL5_2.__lambda1.__lambda2.filter!((a) => a).filter!(int[]).filter | ||
| function b.__unittestL5_2.__lambda1.__lambda2.__lambda2 | ||
| By using `deferredNested` correctly, those nested function generations are ordered again. | ||
| +/ |
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,3 @@ | ||
| module a; | ||
|
|
||
| import imports.std15030algo; |
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,17 @@ | ||
| module b; | ||
|
|
||
| import imports.std15030algo; | ||
|
|
||
| unittest | ||
| { | ||
| auto dg = | ||
| // __lambda1 | ||
| (int[] delegate(int[]) self) => | ||
| // __lambda2 | ||
| (int[] arr) => arr | ||
| ? self([arr.filter!( | ||
| // __lambda2.__lambda2 | ||
| a => a | ||
| ).front]) | ||
| : null; | ||
| } |
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,35 @@ | ||
| module imports.std15030algo; | ||
|
|
||
| template filter(alias pred) | ||
| { | ||
| auto filter(R)(R r) | ||
| { | ||
| return FilterResult!(pred, R)(r); | ||
| } | ||
| } | ||
|
|
||
| private struct FilterResult(alias pred, R) | ||
| { | ||
| R _input; | ||
|
|
||
| this(R r) | ||
| { | ||
| _input = r; | ||
| while (_input.length != 0 && !pred(_input[0])) | ||
| { | ||
| _input = _input[1..$]; | ||
| } | ||
| } | ||
|
|
||
| @property bool empty() { return _input.length == 0; } | ||
|
|
||
| @property auto ref front() { return _input[0]; } | ||
|
|
||
| void popFront() | ||
| { | ||
| do | ||
| { | ||
| _input = _input[1..$]; | ||
| } while (_input.length != 0 && !pred(_input[0])); | ||
| } | ||
| } |