Bug 22156 – Can't use all-types slice of not-all-types AliasSeq as type

Status
REOPENED
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-07-28T19:08:08Z
Last change time
2024-12-13T19:17:42Z
Assigned to
No Owner
Creator
Ate Eskola
Moved to GitHub: dmd#19963 →

Comments

Comment #0 by Ajieskola — 2021-07-28T19:08:08Z
```d import std; AliasSeq!(int, 0)[0..1] a; ``` This should compile, but it does not: ``` app.d(2): Error: `AliasSeq!(int, 0)` is used as a type app.d(2): Error: can only slice tuple types, not `_error_` ```
Comment #1 by razvan.nitu1305 — 2023-02-28T15:37:26Z
Why should this code compile? To be able to slice the type, the compiler requires a valid type? Since AliasSeq!(int, 0) is not a valid type, you cannot slice it. I don't think that this bug report is valid. Tentatively closing as invalid. But please feel free to reopen upon further clarifications. As a workaround, you can first extract the types from the AliasSeq and than create the needed tuple type.
Comment #2 by nick — 2023-02-28T17:54:03Z
Indexing such a sequence compiles fine, so slicing not working is inconsistent: AliasSeq!(int, 0)[0] a; // OK AliasSeq!(int, char, 0)[0..2] b; // NG AliasSeq!(int, char)[0..2] c; // OK
Comment #3 by Ajieskola — 2023-03-03T19:21:57Z
Reopened for reasons explained by Nick.
Comment #4 by robert.schadek — 2024-12-13T19:17:42Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19963 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB