January 12

Hello, I have this code:

import core.lifetime : move, forward;
import std.stdio : writeln;

struct Foo{
    int i;

    static auto make(int i){
    	Foo tmp;
        tmp.i = i;
        return move(tmp);

    this(scope const ref typeof(this) rhs){
    	this.i = rhs.i;

    this(T)(scope const T rhs)
    if(is(immutable T == immutable typeof(this))){
    	this.i = rhs.i;


auto foo(T)(auto ref T x){
	return Foo(forward!x);

void main(){
    Foo x = foo(Foo.make(1));

When is this code compiled with 2.098.1 then it print:

Error: Cannot define both an rvalue constructor and a copy constructor for `struct Foo`
       Template instance `__ctor!(Foo)` creates a rvalue constructor for `struct Foo`
Error: template instance `onlineapp.Foo.__ctor!(Foo)` error instantiating
       instantiated from here: `foo!(Foo)`

When is compiled by dmd-beta/dmd-nightly then it works fine.

Is dmd-beta/dmd-nightly with bug or is this new valid behaviour?

January 12

On Wednesday, 12 January 2022 at 08:04:19 UTC, vit wrote:


Hello, I have this code:


run.dlang.io has old version of dmd-beta/dmd-nightly with bug