August 04, 2012
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


--- Comment #0 from Jonathan M Davis <jmdavisProg@gmx.com> 2012-08-03 21:28:45 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.

This is probably the same as bug# 8138, since that's specifically for attribute 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: -------
August 28, 2012
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


--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2012-08-28 09:42:34 PDT ---
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: -------
January 22, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=8504



--- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> 2013-01-21 23:04:02 PST ---
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: -------
January 22, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=8504



--- Comment #3 from github-bugzilla@puremagic.com 2013-01-22 09:44:15 PST ---
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 Merge pull request #1096 from 9rnsr/fix8504

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: -------
January 24, 2013
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: -------
Top | Discussion index | About this forum | D home