[Issue 24796] New: Confusing irrelevant 'cannot pass rvalue argument' error message on a type error
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Oct 5 01:51:51 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24796
Issue ID: 24796
Summary: Confusing irrelevant 'cannot pass rvalue argument'
error message on a type error
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: andy-hanson at protonmail.com
```
void main() {
foo(Asdf());
}
void foo(in Asdg x) {}
struct Asdf {}
struct Asdg {
int a;
int b;
int c;
int d;
int e;
}
```
Compiling with `dmd a.d -preview=in` I get this error message:
```
a.d(2): Error: function `foo` is not callable using argument types `(Asdf)`
a.d(2): cannot pass rvalue argument `Asdf()` of type `Asdf` to parameter
`in Asdg x`
a.d(5): `a.foo(in Asdg x)` declared here
```
The error message appears to be complaining about an rvalue. The error is
actually just due to using the wrong type, and an rvalue of the correct type
would work.
The issue does not reproduce if the correct type has less than 5 fields.
--
More information about the Digitalmars-d-bugs
mailing list