Thread overview
[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
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

--