www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10498] New: `__traits(compiles, ...)` affect program behaviour

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

           Summary: `__traits(compiles, ...)` affect program behaviour
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: verylonglogin.reg gmail.com


--- Comment #0 from Denis Shelomovskij <verylonglogin.reg gmail.com> 2013-06-29
11:50:51 MSD ---
`{ T; }` delegate makes `static assert` fail:
---
template triggerIssue()
{ enum triggerIssue = __traits(compiles, { T; }); }

template PackedGenericTuple(Args...)
{
    alias Args Tuple;
    enum e = triggerIssue!();
}

struct S { }

template T()
{
    alias T = PackedGenericTuple!S;
}

void main()
{
    alias t = T!();
    static assert(is(t.Tuple[0])); // Fails
}
---

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 29 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10498


Denis Shelomovskij <verylonglogin.reg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|major                       |regression


--- Comment #1 from Denis Shelomovskij <verylonglogin.reg gmail.com> 2013-06-29
11:56:14 MSD ---
Another situation:
---
template triggerIssue(A...)
{ enum triggerIssue = __traits(compiles, { auto a = A[0]; }); }

template PackedGenericTuple(Args...)
{
    alias Args Tuple;
    enum e = triggerIssue!Args;
}

template T()
{
    struct S{} // The fact `S` is in `T` causes the problem
    alias T = PackedGenericTuple!S;
}

void main()
{
    alias t = T!();
    static assert(is(t.Tuple[0]));
}
---

The second one is reduced (no sure if correct) from regression failure.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 29 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10498


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #2 from Kenji Hara <k.hara.pg gmail.com> 2013-06-30 02:30:16 PDT ---
Compiler fix for the first case.
https://github.com/D-Programming-Language/dmd/pull/2280

I'm not sure the second case is really a regression. If not, it should be filed
as a separate issue.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 30 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10498



--- Comment #3 from Kenji Hara <k.hara.pg gmail.com> 2013-06-30 03:28:36 PDT ---
(In reply to comment #2)
 Compiler fix for the first case.
 https://github.com/D-Programming-Language/dmd/pull/2280
 
 I'm not sure the second case is really a regression. If not, it should be filed
 as a separate issue.
OK, indeed the second case would have the same root cause with the first. I updated the PR to fix the both cases. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 30 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10498



--- Comment #4 from github-bugzilla puremagic.com 2013-07-08 03:54:15 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/abbbbc419d0c792a04f715fcd8c60831764dc294
fix Issue 10498 - `__traits(compiles, ...)` affect program behaviour

https://github.com/D-Programming-Language/dmd/commit/6c6765783609e06ef9634f16f6d6a2035da8ec8f
Merge pull request #2280 from 9rnsr/fix10498

[REG2.061] Issue 10498 - `__traits(compiles, ...)` affect program behaviour

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 08 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10498


Kenji Hara <k.hara.pg gmail.com> changed:

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


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