Bug 20731 – checkaction=context fails for structs with 'alias <slice> this'

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-04-13T02:48:39Z
Last change time
2020-04-13T04:32:01Z
Keywords
pull
Assigned to
No Owner
Creator
moonlightsentinel

Comments

Comment #0 by moonlightsentinel — 2020-04-13T02:48:39Z
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!"
Comment #1 by dlang-bot — 2020-04-13T02:54:23Z
@MoonlightSentinel created dlang/druntime pull request #3029 "Fix Issue 20731 - checkaction=context fails for structs with 'alias <slice> this'" fixing this issue: - Fix Issue 20731 - checkaction=context fails for structs with 'alias <slice> this' Exclude structs wich are implicitly convertible to a slice due to `alias this`". https://github.com/dlang/druntime/pull/3029
Comment #2 by dlang-bot — 2020-04-13T04:32:01Z
dlang/druntime pull request #3029 "Fix Issue 20731 - checkaction=context fails for structs with 'alias <slice> this'" was merged into stable: - d15e8ec1ecd8a5c917f9f22c3e4ae2986694ec7d by MoonlightSentinel: Fix Issue 20731 - checkaction=context fails for structs with 'alias <slice> this' Exclude structs wich are implicitly convertible to a slice due to `alias this`". https://github.com/dlang/druntime/pull/3029