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

Issue 9415 - delegate inference should make function literal impure #1572

Merged
merged 1 commit into from Mar 3, 2013

Conversation

9rnsr
Copy link
Contributor

@9rnsr 9rnsr commented Jan 28, 2013

void test9415()
{
int z;
typeof((int a){return z;}) dg;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this line be typed as pure, instead of line 726 as impure?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In current, dg is declared as int delegate(int) pure nothrow @safe.
Because, inside typeof, pureness and safety inference is suppressed in temporary.

So this line is now pure, and line 726 is already impure. But it is a bug. This line should be impure.

Essentially, if a lambda literal contacts to the frame enclosing it, it should be impure.
But there is a few exceptions. In following, lambda literal is inferred to delegate but keeps its pureness.

Bar8751 foo8751b(const int x) pure
{
    return y => x > y; // pure delegate
}

WalterBright added a commit that referenced this pull request Mar 3, 2013
Issue 9415 - delegate inference should make function literal impure
@WalterBright WalterBright merged commit a5ab2c3 into dlang:master Mar 3, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants