import std.typecons : tuple; enum foo = tuple(1, 2).expand; // Compiles up to 2.071.2 and with PR #6517 pragma(msg, typeof(foo).stringof); pragma(msg, foo.stringof); void bar() { auto roo = tuple(1, 2).expand; // OK pragma(msg, typeof(roo).stringof); pragma(msg, roo.stringof); } void baz() { enum zoo = tuple(1, 2).expand; // Error: value of __tup1847 is not known at compile time pragma(msg, typeof(zoo).stringof); pragma(msg, zoo.stringof); }
This seems to be a regression. Introduced in https://github.com/dlang/dmd/pull/3672
Would be nice to have a test case that doesn't rely on Phobos?
This compiles from 2.064 to 2.071.2, and again from 2.073.2: auto tuple(T...)(T t) { struct Result { T expand; } return Result(t); } enum foo = tuple(1, 2).expand; pragma(msg, typeof(foo).stringof); pragma(msg, foo.stringof); void bar() { auto roo = tuple(1, 2).expand; // OK pragma(msg, typeof(roo).stringof); pragma(msg, roo.stringof); } This compiles from 2.064 to 2.065.0, but fails ever since: auto tuple(T...)(T t) { struct Result { T expand; } return Result(t); } void baz() { enum zoo = tuple(1, 2).expand; // Error: value of __tup1847 is not known at compile time pragma(msg, typeof(zoo).stringof); pragma(msg, zoo.stringof); }
@WalterBright created dlang/dmd pull request #10774 "fix Issue 17145 - [REG2.066.0] Tuple expansion error in local enum de…" fixing this issue: - fix Issue 17145 - [REG2.066.0] Tuple expansion error in local enum declaration https://github.com/dlang/dmd/pull/10774
dlang/dmd pull request #10774 "fix Issue 17145 - [REG2.066.0] Tuple expansion error in local enum de…" was merged into master: - e1a04df28118fe1e7cf47dde26e1f896630e585a by Walter Bright: fix Issue 17145 - [REG2.066.0] Tuple expansion error in local enum declaration https://github.com/dlang/dmd/pull/10774