dmd icon indicating copy to clipboard operation
dmd copied to clipboard

static if declaration leads to nonsense error

Open adamdruppe opened this issue 6 months ago • 1 comments

// bugrepro1.d
import bugrepro2;

class Foo {
	Timer t;

	this() {
		t = new Timer;
	}
}

static if(false)
	alias Timer = bugrepro2.Timer;
else
	class Timer{}

and

// bugrepro2.d
class Timer {}

build with dmd bugrepo1 (master as well as old version):

bugrepro1.d(7): Error: cannot implicitly convert expression new Timer of type bugrepro1.Timer to bugrepro2.Timer t = new Timer;

Error disappears if you put the class below the static if, but supposed to be order independent.

adamdruppe avatar Apr 21 '25 16:04 adamdruppe