Bug 24796 – Confusing irrelevant 'cannot pass rvalue argument' error message on a type error

Status
NEW
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2024-10-05T01:51:51Z
Last change time
2024-12-13T19:37:51Z
Assigned to
No Owner
Creator
andy-hanson
Moved to GitHub: dmd#18272 →

Comments

Comment #0 by andy-hanson — 2024-10-05T01:51:51Z
``` 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.
Comment #1 by robert.schadek — 2024-12-13T19:37:51Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18272 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB