Bug 16685 – template instantiation rejected when passing member of enum struct in value parameter
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-11-14T12:48:23Z
Last change time
2018-02-08T15:54:05Z
Keywords
rejects-valid
Assigned to
No Owner
Creator
Eyal Lotem
Comments
Comment #0 by eyal.lotem — 2016-11-14T12:48:23Z
Failing to instantiate a template from a correctly-typed compile-time value:
struct Id { ushort value; }
enum Id x = Id(5);
struct S(ushort A) {}
// This works, as expected:
enum ushort someShortVal = 5;
alias CanCreateFromShort = S!(someShortVal);
// This works, as expected:
alias CanCreateFromTypedValue = S!(ushort(x.value));
static assert(is(typeof(x.value) == ushort));
// This surprisingly fails
alias CannotCreateFromValue = S!(x.value);