Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8941 from dlang/thewilsonator-patch-3
Fix issue 16976 - Do not convert blindly the size of an iterable merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>
- Loading branch information
Showing
4 changed files
with
56 additions
and
1 deletion.
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,23 @@ | ||
/* REQUIRED_ARGS: -m64 | ||
TEST_OUTPUT: | ||
--- | ||
compilable/b16976.d(15): Deprecation: foreach: loop index implicitly converted from `size_t` to `int` | ||
compilable/b16976.d(16): Deprecation: foreach: loop index implicitly converted from `size_t` to `int` | ||
compilable/b16976.d(17): Deprecation: foreach: loop index implicitly converted from `size_t` to `char` | ||
compilable/b16976.d(18): Deprecation: foreach: loop index implicitly converted from `size_t` to `char` | ||
--- | ||
*/ | ||
void main() | ||
{ | ||
int[] dyn = [1,2,3,4,5]; | ||
int[5] sta = [1,2,3,4,5]; | ||
|
||
foreach(int i, v; dyn) { } | ||
foreach_reverse(int i, v; dyn) { } | ||
foreach(char i, v; dyn) { } | ||
foreach_reverse(char i, v; dyn) { } | ||
foreach(int i, v; sta) { } | ||
foreach_reverse(int i, v; sta) { } | ||
foreach(char i, v; sta) { } | ||
foreach_reverse(char i, v; sta) { } | ||
} |
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,18 @@ | ||
/* TEST_OUTPUT: | ||
--- | ||
fail_compilation/diag16976.d(14): Error: foreach: key cannot be of non-integral type `float` | ||
fail_compilation/diag16976.d(15): Error: foreach: key cannot be of non-integral type `float` | ||
fail_compilation/diag16976.d(16): Error: foreach: key cannot be of non-integral type `float` | ||
fail_compilation/diag16976.d(17): Error: foreach: key cannot be of non-integral type `float` | ||
--- | ||
*/ | ||
|
||
void main() | ||
{ | ||
int[] dyn = [1,2,3,4,5]; | ||
int[5] sta = [1,2,3,4,5]; | ||
foreach(float f, i; dyn) {} | ||
foreach(float f, i; sta) {} | ||
foreach_reverse(float f, i; dyn) {} | ||
foreach_reverse(float f, i; sta) {} | ||
} |
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