D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 17145 - [REG2.066.0] Tuple expansion error in local enum declaration
Summary: [REG2.066.0] Tuple expansion error in local enum declaration
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 regression
Assignee: No Owner
URL:
Keywords: CTFE, pull, rejects-valid
Depends on:
Blocks:
 
Reported: 2017-02-04 12:02 UTC by Adrian Matoga
Modified: 2020-02-09 23:16 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Adrian Matoga 2017-02-04 12:02:28 UTC
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);
}
Comment 1 Vladimir Panteleev 2017-07-02 01:57:02 UTC
This seems to be a regression.

Introduced in https://github.com/dlang/dmd/pull/3672
Comment 2 Walter Bright 2018-12-16 10:50:18 UTC
Would be nice to have a test case that doesn't rely on Phobos?
Comment 3 Simen Kjaeraas 2018-12-17 09:36:40 UTC
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);
}
Comment 4 Dlang Bot 2020-02-09 09:21:09 UTC
@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
Comment 5 Dlang Bot 2020-02-09 23:16:37 UTC
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