[Issue 24869] New: Qualifier dropped from return type when AliasSeq is indexed with template argument
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Nov 20 16:34:07 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24869
Issue ID: 24869
Summary: Qualifier dropped from return type when AliasSeq is
indexed with template argument
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: snarwin+bugzilla at gmail.com
As of DMD 2.109.1, the following program fails to compile:
---
alias AliasSeq(Args...) = Args;
struct S
{
int n;
ref const(AliasSeq!(int)[i]) get(size_t i)() const => n;
}
void main()
{
const S s;
s.get!0;
}
---
The error message is:
---
bug.d(6): Error: expression `this.n` of type `const(int)` is not implicitly
convertible to return type `ref int`
bug.d(12): Error: template instance `bug.S.get!0LU` error instantiating
---
As show in the error message, the compiler has erroneously determined the
return type of `get!0` to be `int`, when it should instead be `const(int)`.
The same error also occurs with the immutable, inout, and shared qualifiers.
--
More information about the Digitalmars-d-bugs
mailing list