Thread overview
[Issue 5830] New: Bug in alias resolution for template value parameters in is()?
Apr 10, 2011
klickverbot
Apr 10, 2011
Piotr Szturmaj
Jul 12, 2011
yebblies
April 10, 2011
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


--- Comment #0 from klickverbot <code@klickverbot.at> 2011-04-10 14:19:59 PDT ---
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: -------
April 10, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5830


Piotr Szturmaj <pszturmaj@tlen.pl> changed:

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


--- Comment #1 from Piotr Szturmaj <pszturmaj@tlen.pl> 2011-04-10 15:35:42 PDT ---
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: -------
July 12, 2011
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


--- Comment #2 from yebblies <yebblies@gmail.com> 2011-07-12 18:31:22 EST ---
*** 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: -------