www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10329] New: Attributes not inferred for indirectly templated methods

reply d-bugmail puremagic.com writes:
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



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: -------
Jun 10 2013
next sibling parent d-bugmail puremagic.com writes:
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



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: -------
Jun 11 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10329




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: -------
Jun 14 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
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



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: -------
Jun 25 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10329


monarchdodra gmail.com changed:

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



*** 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: -------
Aug 24 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10329




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: -------
Oct 16 2013