Bug 22600 – Better error message when trying to assign non-implicitily convertible slices

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-12-15T05:57:38Z
Last change time
2024-12-13T19:19:50Z
Keywords
diagnostic
Assigned to
No Owner
Creator
Răzvan Ștefănescu
Moved to GitHub: dmd#20023 →

Comments

Comment #0 by rumbu — 2021-12-15T05:57:38Z
In the code below: struct A { int x; } struct B { int y; } A[] bufa; B[] bufb; bufa[0] = bufb[0]; The error message is "cannot implicitly convert expression `bufb[0]` of type `B` to `A`" Trying to do a slice assignment: bufa[] = bufb[]; will render another error message: "cannot implicitly convert expression `bufb[]` of type `B[]` to `A[]". Since the root cause is the first one, I think the error message must also state that 'B' si not implicitily convertible to 'A' instead of highlight that sorresponding slices are incompatible. This example is simple, but if A and B are some long names (e.g. template instantiations), the error message is difficult to gasp and makes you think that is a problem with slice assignment, not with the basic assignment of B to A.
Comment #1 by robert.schadek — 2024-12-13T19:19:50Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20023 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB