www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6265] New: Pure-inference doesn't apply with template alias parameter of function

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

           Summary: Pure-inference doesn't apply with template alias
                    parameter of function
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Mac OS X
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: kennytm gmail.com



Test case:

----------------------
pure int h() {
    return 1;
}
int f(alias g)() {
    return g();
}
pure int i() {
    return f!h();
}
----------------------
x.d(8): Error: pure function 'i' cannot call impure function 'f'
----------------------

The instantiation f!h should be detected as pure, but currently DMD on git
master fails to do so.

nothrow and  safe are correctly inferred.

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


kennytm gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Pure-inference doesn't      |Pure-inference failed when
                   |apply with template alias   |calling other pure
                   |parameter of function       |functions



Actually the problem is not due to the template alias parameter, but because
'CallExp::semantic' calls 'Expression::checkPurity' which calls
'FuncDeclaration::isPure' on the outer function, and stops its inference with
'setImpure'.



Two more test cases:

------------------------
pure int h() {
    return 1;
}
int f()() {
    return h();
}
pure int i() {
    return f();
}
-------------------------


-------------------------
pure int h() {
    return 1;
}
pure int i() {
    return {
        return h();
    }();
}
-------------------------

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


kennytm gmail.com changed:

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





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

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


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED



00:02:20 PDT ---
https://github.com/D-Programming-Language/dmd/commit/b4107b88a3acac76f31bafcad664c48df760ee01

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