Bug 23971 – Provide clearer error message when trying to return a slice with C++ linkage

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-06-05T11:31:36Z
Last change time
2023-06-24T17:02:21Z
Keywords
pull
Assigned to
No Owner
Creator
Marcelo Silva Nascimento Mancini
See also
https://issues.dlang.org/show_bug.cgi?id=18716

Comments

Comment #0 by msnmancini — 2023-06-05T11:31:36Z
```d extern(C++) const(char)[] hello() { return "Hello"; } ``` I believe it would be better to get a better message such as "it is disallowed to return D slices from C++ linkage since they have no representable mangling in C++" or something like that.
Comment #1 by msnmancini — 2023-06-05T11:31:59Z
Oh yea, the current error message is pretty bad: `cannot return type const(char)[] because its linkage is extern(C++)`
Comment #2 by dlang-bot — 2023-06-21T08:14:32Z
@RazvanN7 created dlang/dmd pull request #15336 "Fix Issue 23971 - Provide clearer error message when trying to return…" fixing this issue: - Fix Issue 23971 - Provide clearer error message when trying to return a slice with C++ linkage https://github.com/dlang/dmd/pull/15336
Comment #3 by dlang-bot — 2023-06-21T11:17:03Z
dlang/dmd pull request #15336 "Fix Issue 23971 - Provide clearer error message when trying to return…" was merged into master: - 6b4d03967de2a02d770107ce48037c325bb1bad6 by RazvanN7: Fix Issue 23971 - Provide clearer error message when trying to return a slice with C++ linkage https://github.com/dlang/dmd/pull/15336