Summary: Template attribute inferrence doesn't work
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: critical
          Priority: P2
         Component: DMD

--- Comment #0 from Jonathan M Davis <> 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) ==;

results in this output

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:
------- You are receiving this mail because: -------

Reply via email to