Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Regression 2.066 - 2.067.1] nested pure functions variable access #19584

Open
dlangBugzillaToGithub opened this issue Jun 14, 2019 · 3 comments
Labels
P1 Severity:Regression PRs that fix regressions

Comments

@dlangBugzillaToGithub
Copy link

Nicholas Wilson (@thewilsonator) reported this on 2019-06-14T10:46:17Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=19963

CC List

Description

From the source code of DMD no less!

void f() {
  int fx;
  pure void g() {
    int gx;
    /+pure+/ void h() {
      int hx;
      /+pure+/ void i() { fx = 0; }
    }
   }
}

should give 

Error: pure nested function 'g' cannot access mutable data 'fx'
if the commented out `purees are removed it should give 

Error: pure nested function 'i' cannot access mutable data 'fx'

three times.
@dlangBugzillaToGithub
Copy link
Author

iamthewilsonator commented on 2019-06-14T11:28:43Z

*** Issue 19964 has been marked as a duplicate of this issue. ***

@dlangBugzillaToGithub
Copy link
Author

bugzilla (@WalterBright) commented on 2019-12-18T10:44:28Z

I'm not sure what the problem is?

@dlangBugzillaToGithub
Copy link
Author

razvan.nitu1305 commented on 2020-02-13T11:01:26Z

The problem is that function g is pure, but it contains function i that accesses the variable fx which is outside of its scope, thus violating purity. This code should issue an error, but it doesn't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 Severity:Regression PRs that fix regressions
Projects
None yet
Development

No branches or pull requests

1 participant