Bug 5830 – Bug in alias resolution for template value parameters in is()?
Status
RESOLVED
Resolution
DUPLICATE
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Mac OS X
Creation time
2011-04-10T14:19:00Z
Last change time
2011-07-12T01:31:22Z
Keywords
rejects-valid
Assigned to
nobody
Creator
code
Comments
Comment #0 by code — 2011-04-10T14:19:59Z
With current DMD 2 (0219a5f), the following snippet does not compile:
---
template isBar(T) {
static if (is(T _ : Bar!(v), string v)) {
enum isBar = true;
} else {
enum isBar = false;
}
}
struct Bar(string v) {}
pragma(msg, isBar!(Bar!("bar")));
---
The error message is: »Error: undefined identifier string«.
However, if »string« is replaced with »immutable(char)[]« in the is expression, it gives the intended result:
---
template isBar(T) {
static if (is(T _ : Bar!(v), immutable(char)[] v)) {
enum isBar = true;
} else {
enum isBar = false;
}
}
struct Bar(string v) {}
pragma(msg, isBar!(Bar!("bar"))); // prints true
---
Comment #1 by pszturmaj — 2011-04-10T15:35:42Z
I can confirm that. I had the same error with size_t (DMD 2.052). In case of string, workaround is simple but for size_t it's not since size_t depends on word size.
Comment #2 by yebblies — 2011-07-12T01:31:22Z
*** This issue has been marked as a duplicate of issue 2355 ***