Bug 13818 – Unhelpful error message for rvalue reference: incompatible types for ((S()) + (S())): 'S' and 'S'

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-12-04T18:45:09Z
Last change time
2024-12-13T18:38:14Z
Assigned to
No Owner
Creator
Ali Cehreli
Moved to GitHub: dmd#17690 →

Comments

Comment #0 by acehreli — 2014-12-04T18:45:09Z
struct S { void opBinary(string op)(ref S rhs) {} } void main() { auto result = S() + S(); } Error: incompatible types for ((S()) + (S())): 'S' and 'S' The message is bogus because S is compatible with S. ;)
Comment #1 by n8sh.secondary — 2019-08-23T21:28:02Z
As of https://github.com/dlang/dmd/pull/7441 the error message is "Error: incompatible types for (S()) + (S()): both operands are of type S".
Comment #2 by acehreli — 2019-08-25T14:19:59Z
There is no issue with both operands being S. The issue seems to be the fact that the second operand is an rvalue. So, a helpful message would be "cannot bind rvalue S to ref parameter". Ali
Comment #3 by robert.schadek — 2024-12-13T18:38:14Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17690 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB