D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5830 - Bug in alias resolution for template value parameters in is()?
Summary: Bug in alias resolution for template value parameters in is()?
Status: RESOLVED DUPLICATE of issue 2355
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Mac OS X
: P2 critical
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2011-04-10 14:19 UTC by David Nadlinger
Modified: 2011-07-12 01:31 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description David Nadlinger 2011-04-10 14:19:59 UTC
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 Piotr Szturmaj 2011-04-10 15:35:42 UTC
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 yebblies 2011-07-12 01:31:22 UTC

*** This issue has been marked as a duplicate of issue 2355 ***