www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8504] New: Template attribute inferrence doesn't work

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

           Summary: Template attribute inferrence doesn't work
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: jmdavisProg gmx.com



PDT ---
This code

import std.stdio;
import std.traits;

void func(R)(R range)
{
}

void main()
{
    pragma(msg, mangledName!(func!string));
    static assert(functionAttributes!(func!string) == FunctionAttribute.safe);
}

results in this output

_D1y13__T4funcTAyaZ4funcFAyaZv
y.d(11): Error: static assert  (0u == cast(FunctionAttribute)1u) is false

func is templatized and has _nothing_ in it, so it should be inferred as  safe,
pure, and nothrow, but as evidenced by the name mangling and complete lack of
function attributes, it has been marked with none of those. The fact that this
_really_ basic function isn't inferring any attributes makes it seem likely
that attributes aren't ever getting inferred for any functions. Certainly,
nothing I've tried thus far has resulted in any attributes being inferred
(including adding  safe function calls to func, so it's not related to the fact
that func is empty). And this code didn't work in the version of dmd when
attribute inferrence was supposedly introduced (2.054) - or any version since
then - so I have no idea what attribute inferrence is supposedly going on,
since it's clearly not working.


inferrence and Voldemort types, but if attribute inferrence isn't working for
templates at all, then it's certainly not going to work for Voldemort types.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 03 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8504


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, wrong-code
            Version|unspecified                 |D2



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

After semantic3 (semantics for function body code) done, typeof(func!string)
returns 'pure nothrow  safe void(string)' because of the attribute inference,
but it doesn't affect to its mangled name. That's a bug.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 28 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8504




A simple test case from: http://d.puremagic.com/issues/show_bug.cgi?id=6902#c6

cat > bug.d << CODE
void a()
{
    function void() { }();
}

void b()
{
    static void safe_nothrow()  safe nothrow pure { }
    auto f = &safe_nothrow;
    enum mangle = typeof(*f).mangleof;
    static assert(mangle == "FNaNbNfZv", mangle);
}
CODE

dmd -c bug

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




Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/f9d53eb403cbe29310cc501ad099acddb71cac75
fix Issue 8504 - Template attribute inferrence doesn't work

https://github.com/D-Programming-Language/dmd/commit/6344a72ac2e2e597110891f7aed4b998d58f61fd


Issue 8504 - Template attribute inferrence doesn't work

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


Martin Nowak <code dawg.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |code dawg.eu
         Resolution|                            |FIXED


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