[Issue 22964] New: array cast message is awkwardly worded
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Mar 31 14:38:15 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=22964
Issue ID: 22964
Summary: array cast message is awkwardly worded
Product: D
Version: D2
Hardware: x86
OS: Mac OS X
Status: NEW
Severity: enhancement
Priority: P1
Component: druntime
Assignee: nobody at puremagic.com
Reporter: schveiguy at gmail.com
Given the following code:
```d
auto str = "hello";
auto wstr = cast(wstring)str;
```
The array cast cannot complete, because it would require 2.5 wchars. Regardless
of the correctness of this attempt, the message is confusing:
```
An array of size 5 does not align on an array of size 4, so `immutable(char)`
cannot be cast to `immutable(wchar)`
```
1. I never requested an array of size 4, so I'm not sure why that is in the
message.
2. It's not a matter of alignment, but of size.
3. You can cast an immutable char to an immutable wchar, so the message is
wrong
4. The bytes are displayed here, not the lengths, which isn't as useful, there
is no need to have the user work out the math.
I am writing a PR to fix this message, this is the bug report for that fix.
--
More information about the Digitalmars-d-bugs
mailing list