Thread overview
[Issue 7616] aggregates don't inherit pure, @nogc, nothrow from outer scope
[Issue 7616] aggregates don't inherit pure nothrow from outer scope
Dec 13, 2018
|
Dec 14, 2018
Neia Neutuladh
Dec 17, 2018
Radu Racariu
Dec 17, 2022
Iain Buclaw
Aug 03
Dlang Bot
Aug 03
Dlang Bot
August 18, 2014
https://issues.dlang.org/show_bug.cgi?id=7616

hsteoh@quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hsteoh@quickfur.ath.cx

--- Comment #2 from hsteoh@quickfur.ath.cx ---
Gah, this is a mess. On git HEAD, the original produces this output:
------
@safe void()
pure nothrow @safe void()
------

which seems to indicate that "pure nothrow:" has no effect.

Commenting out the "pure nothrow:" line in Foo2 produces:
------
@safe void()
@safe void()
------

So basically, "pure nothrow:" doesn't work at all.

--
December 13, 2018
https://issues.dlang.org/show_bug.cgi?id=7616

| <dhasenan@gmail.com> changed:

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

--- Comment #3 from | <dhasenan@gmail.com> ---
https://github.com/dlang/dmd/pull/9076

--
December 14, 2018
https://issues.dlang.org/show_bug.cgi?id=7616

Neia Neutuladh <dhasenan@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid

--- Comment #4 from Neia Neutuladh <dhasenan@gmail.com> ---
The spec at https://dlang.org/spec/attribute.html says:

attribute:     // affects all declarations until the end of
               // the current scope

The obvious interpretation is that any declaration between `attribute:` and the end of the current scope should have `attribute` applied. This includes nested declarations.

A version that doesn't include nested declarations would say something like "affects all declarations within the current scope after `attribute:`", ideally with clarification about nested scopes.

If there were any such text, then @safe would need to *not* propagate for consistency, *or* there would need to be other text saying that @safe propagates differently (which currently there isn't).

More illustrative test case:

---
nothrow pure
{
struct Foo
{
  int b() { return 1; }
}
}
int k() nothrow pure
{
  Foo foo;
  return foo.b();
}
---

Expected result: k() returns 1.
Actual result:
scratch.d(11): Error: pure function scratch.k cannot call impure function
scratch.Foo.b
scratch.d(11): Error: function scratch.Foo.b is not nothrow
scratch.d(8): Error: nothrow function scratch.k may throw

--
December 17, 2018
https://issues.dlang.org/show_bug.cgi?id=7616

Radu Racariu <radu.racariu@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=19472

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=7616

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P3

--
August 03
https://issues.dlang.org/show_bug.cgi?id=7616

Nick Treleaven <nick@geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nick@geany.org
            Summary|aggregates don't inherit    |aggregates don't inherit
                   |pure nothrow from outer     |pure, @nogc, nothrow from
                   |scope                       |outer scope

--
August 03
https://issues.dlang.org/show_bug.cgi?id=7616

--- Comment #5 from Dlang Bot <dlang-bot@dlang.rocks> ---
@ntrel created dlang/dlang.org pull request #3893 "[spec] Improve attribute propagation docs" mentioning this issue:

- [spec] Improve attribute propagation docs

  Part of Bugzilla 7616 - aggregates don't inherit pure nothrow from outer
scope

  Add grammar heading.
  `@nogc`, `nothrow` and `pure` do not propagate inside aggregates.
  Add example.
  Add link to core.attribute.

https://github.com/dlang/dlang.org/pull/3893

--
August 03
https://issues.dlang.org/show_bug.cgi?id=7616

--- Comment #6 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dlang.org pull request #3893 "[spec] Improve attribute propagation docs" was merged into master:

- d55c919d5de5e34235c24f40eb734d54d40f83e1 by Nick Treleaven:
  [spec] Improve attribute propagation docs

  Part of Bugzilla 7616 - aggregates don't inherit pure nothrow from outer
scope

  Add grammar heading.
  `@nogc`, `nothrow` and `pure` do not propagate inside aggregates.
  Add example.
  Add link to core.attribute.

https://github.com/dlang/dlang.org/pull/3893

--