[Issue 20731] New: checkaction=context fails for structs with 'alias <slice> this'
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Apr 13 02:48:39 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=20731
Issue ID: 20731
Summary: checkaction=context fails for structs with 'alias
<slice> this'
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: druntime
Assignee: nobody at puremagic.com
Reporter: moonlightsentinel at disroot.org
The following snippet causes a compilation failure / wrong formatting depending
on whether a is const/mutable:
----------------------------------------------
struct S
{
int[2] arr;
int[] get() { return arr[]; }
alias get this;
}
const a = S([1, 2]);
assert(a == S([3, 4]);
-----------------------------------------------
Mutable: "[1, 2] != [3, 4]" instead of "S([1, 2]) != S([3, 4])".
Const: "Mutable method `get` is not callable using a `const` object!"
--
More information about the Digitalmars-d-bugs
mailing list