Summary: Inconsistency in overloading ref vs. non-ref
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD

--- Comment #0 from David Simcha <> 2010-09-09 06:03:33 PDT ---
The following code compiles and correctly resolves the lvalue vs. non-lvalue

import std.stdio;

void doStuff(const ref int i) {
    writeln("Doing stuff by ref.");

void doStuff(const int i) {
    writeln("Forwarding to ref overload.");

void main() {

Similar code also works for classes and arrays.  It seems to be broken for
structs, though.  The following code is rejected:

import std.stdio;

struct S {}

bool fun(const ref S rhs) {
    return true;

bool fun(const S rhs) {
    return fun(rhs);

test9.d(12): Error: function called with argument types:
matches both: const const(S) rhs)
and: const(S) rhs)

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to