www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5830] New: Bug in alias resolution for template value parameters in is()?

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5830

           Summary: Bug in alias resolution for template value parameters
                    in is()?
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Mac OS X
            Status: NEW
          Keywords: rejects-valid
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: code klickverbot.at



---
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
---

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 10 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5830


Piotr Szturmaj <pszturmaj tlen.pl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pszturmaj tlen.pl



---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 10 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5830


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |yebblies gmail.com
         Resolution|                            |DUPLICATE



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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 12 2011