[Issue 22006] New: static foreach and foreach over tuple doesn't work on 16-bit
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jun 8 15:41:51 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=22006
Issue ID: 22006
Summary: static foreach and foreach over tuple doesn't work on
16-bit
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: major
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: ibuclaw at gdcproject.org
Despite `size_t` being a 16-bit foreach complains when the index type is a
non-int, non-long type.
i.e:
```
alias AliasSeq(TList...) = TList;
alias size_t = ushort;
void foo(int a, int b, int c)
{
foreach (size_t i, e; [0, 1, 2, 3]) { } // OK
static foreach (size_t i, e; [0, 1, 2, 3]) { } // Error
foreach (size_t i, e; AliasSeq!(0, 1, 2, 3)) { } // Error
}
```
Because the length of tuples are known at compile-time, there should be no
reason that the same logic as static arrays isn't applied here too.
--
More information about the Digitalmars-d-bugs
mailing list