Bug 22090 – "alias this" conflicts with concatenating array with element

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-06-29T07:46:42Z
Last change time
2024-12-13T19:17:25Z
Keywords
wrong-code
Assigned to
No Owner
Creator
Vladimir Panteleev
Moved to GitHub: dmd#19956 →

Comments

Comment #0 by dlang-bugzilla — 2021-06-29T07:46:42Z
////////// test.d ////////// struct S { S[] sub; alias sub this; } void main() { S s; S[] arr; arr = arr ~ s; assert(arr.length == 1); } //////////////////////////// The assertion fails. Instead of doing the expected thing and concatenating s to arr, the compiler chooses to concatenate arr with s.sub. Note that arr ~= s; works as expected.
Comment #1 by robert.schadek — 2024-12-13T19:17:25Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19956 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB