Thread overview
[Issue 7432] DMD allows variables to be declared as pure
Jul 01, 2020
Basile-z
Jun 11, 2022
Dlang Bot
Dec 17, 2022
Iain Buclaw
Mar 11, 2023
Dennis
Mar 11, 2023
Stewart Gordon
Mar 11, 2023
Dennis
July 01, 2020
https://issues.dlang.org/show_bug.cgi?id=7432

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|rejects-valid               |accepts-invalid
                 CC|                            |b2.temp@gmx.com

--
June 11, 2022
https://issues.dlang.org/show_bug.cgi?id=7432

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #20 from Dlang Bot <dlang-bot@dlang.rocks> ---
@dkorpel created dlang/dmd pull request #14199 "Fix Issue 7432 - DMD allows variables to be declared as pure" fixing this issue:

- Fix Issue 7432 - DMD allows variables to be declared as pure

https://github.com/dlang/dmd/pull/14199

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

Iain Buclaw <ibuclaw@gdcproject.org> changed:

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

--
March 11, 2023
https://issues.dlang.org/show_bug.cgi?id=7432

Dennis <dkorpel@live.nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |dkorpel@live.nl
         Resolution|---                         |WONTFIX

--- Comment #21 from Dennis <dkorpel@live.nl> ---
I've tried to 'fix' this (see the linked PR), but it turns out function attributes do have a meaning on variable declarations: the function/delegate type inherits them. Existing code relies on this.

If the variable doesn't have such a callable type, applying function attributes could still be made an error, but this isn't straightforward: the type could be determined by a complex template instantiation. Figuring out whether the function attribute did end up affecting anything is:

- complex to specify
- difficult to implement
- hampered by generic code (e.g. when you give a variable either a callable or
non-callable type depending on static introspection)

Because of this, I'm closing this as WONTFIX. I suggest Dscanner may catch trivial cases like `pure int x = 0;` if this turns out to be a helpful warning, though I don't think it's a big problem if a variable is accidentally declared `pure`.

--
March 11, 2023
https://issues.dlang.org/show_bug.cgi?id=7432

--- Comment #22 from Stewart Gordon <smjg@iname.com> ---
I was beginning to think this makes it part of the function type rather than being a declaration attribute.  I make out from what you say that, for reasons of parsing convenience, syntactically it's a declaration attribute but the semantic of it thereas is to pass it through so that it becomes part of the function type.  Have I got this right?

--
March 11, 2023
https://issues.dlang.org/show_bug.cgi?id=7432

--- Comment #23 from Dennis <dkorpel@live.nl> ---
(In reply to Stewart Gordon from comment #22)
> Have I got this right?

Yes

--