Thread overview
[Issue 10329] New: Attributes not inferred for indirectly templated methods
Jun 11, 2013
Andrej Mitrovic
Jun 25, 2013
Henning Pohl
June 11, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10329

           Summary: Attributes not inferred for indirectly templated
                    methods
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: blocker
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: bugzilla@kyllingen.net


--- Comment #0 from Lars T. Kyllingstad <bugzilla@kyllingen.net> 2013-06-10 23:04:32 PDT ---
Currently, attributes such as @safe, pure and nothrow are automatically inferred for function templates.  They should also be inferred for methods of struct/class templates and for Voldemort types.

Test case:

  struct S1
  {
      void foo(T)() { }
  }

  struct S2(T)
  {
      void foo() { }
  }

  auto makeS3(T)()
  {
      struct S3
      {
          void foo() { }
      }
      return S3();
  }

  void main() @safe pure nothrow
  {
      // Works
      S1 s1;
      s1.foo!int();

      // Compilation failure
      S2!int s2;
      s2.foo();

      // Compilation failure
      auto s3 = makeS3!int();
      s3.foo();
  }

This currently prevents large parts of Phobos from being used in @safe/pure/nothrow contexts, and it prevents parts of Phobos from being marked as such.  It also blocks some changes to std.path that I have in the pipeline, because I want to reimplement a function in terms of std.algorithm functions without removing its current attributes (as this would be a breaking change).

A workaround (which is *not* feasible for use in Phobos) is to make the methods themselves trivial templates:

  struct S2(T)
  {
      void foo()() { }
  }

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 11, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10329


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich@gmail.com


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-06-11 07:25:06 PDT ---
Yeah, I think Kenji also mentioned he'd like to see this implemented.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 14, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10329



--- Comment #2 from Lars T. Kyllingstad <bugzilla@kyllingen.net> 2013-06-14 12:27:31 PDT ---
Attributes should also be inferred for functions nested in function templates:

  void foo(T)()
  {
      void inner() { }
      inner();
  }

  void main() @safe pure nothrow
  {
      // Compilation failure:
      foo!int();
  }

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 25, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10329


Henning Pohl <henning@still-hidden.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, rejects-valid
                 CC|                            |henning@still-hidden.de


--- Comment #3 from Henning Pohl <henning@still-hidden.de> 2013-06-25 13:20:38 PDT ---
https://github.com/D-Programming-Language/dmd/pull/2259

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 24, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10329


monarchdodra@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monarchdodra@gmail.com


--- Comment #4 from monarchdodra@gmail.com 2013-08-24 10:24:04 PDT ---
*** Issue 10878 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 16, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10329



--- Comment #5 from hsteoh@quickfur.ath.cx 2013-10-16 14:32:21 PDT ---
This bug makes std.range.chain unusable in pure code.

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