[Issue 7432] DMD allows variables to be declared as pure

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Mar 11 13:40:12 UTC 2023


https://issues.dlang.org/show_bug.cgi?id=7432

Dennis <dkorpel at live.nl> changed:

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

--- Comment #21 from Dennis <dkorpel at 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`.

--


More information about the Digitalmars-d-bugs mailing list