www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6602] New: Invalid template instantiations »leaked« by is(typeof())/__traits(compiles, …)/Type::trySemantic

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

           Summary: Invalid template instantiations »leaked« by
                    is(typeof())/__traits(compiles, …)/Type::trySemantic
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Mac OS X
            Status: NEW
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: code klickverbot.at



---
Okay, turns out that the »collateral regression« the fix for bug 6220 caused
in
my code ([1]) really is a fundamental problem with how DMD handles template
instantiations in the face of error gagging, in this case because is(typeof())
is used (same for __traits(compiles, …)):

---
template A(T) {
  B!(T).Result result;
}

template B(U) {
  static assert(is(U == int));
  alias bool Result;
}

pragma(msg, is(typeof(A!short)));
---

The static assert in B!() should just cause is(typeof()) to evaluate to false,
but B!short is also added to the module member list, causing compilation to
fail because of !is(short == int).

I am working on a fix, but need an issue number to reference.


[1]
https://github.com/D-Programming-Language/dmd/commit/60f4ec88decbcd00e765ab392bf8be8f526ed1ab#commitcomment-535706

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




---
Wish I had discovered that earlier, not just from a bugzilla reference in the
DMD source after I tracked the problem down: A very similar bug has already
been reported, issue 4302. However, the fix proposed there (which got committed
in e66a3a5) only hides the issue for static if conditionals, while it can also
appear if trySemantic() is attempted outside them, see above.

I think the correct solution for the problem is to remove the template instance
from the member list of the enclosing scope again if instantiation failed while
errors were gagged:

https://github.com/D-Programming-Language/dmd/pull/364

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


klickverbot <code klickverbot.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch



---
(I realize that A!short would never have a type, even if B!short could be
instantiated, but this is not important here.)

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


klickverbot <code klickverbot.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



---
https://github.com/D-Programming-Language/dmd/commit/3da0a36698b9cc424dbc8f6e7b2786768ae50f84

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


klickverbot <code klickverbot.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schveiguy yahoo.com



---
*** Issue 6385 has been marked as a duplicate of this issue. ***

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


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com



16:50:52 PDT ---
https://github.com/D-Programming-Language/dmd/commit/3da0a36698b9cc424dbc8f6e7b2786768ae50f84

https://github.com/D-Programming-Language/dmd/commit/5c236d7583f05d10aa55126e16abd00b6e4ff458

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