Skip to content

Issue 9620 - Error messages of failed pure enforcement - #2790

Closed
yebblies wants to merge 1 commit into
dlang:masterfrom
yebblies:issue6920
Closed

yebblies wants to merge 1 commit into
dlang:masterfrom
yebblies:issue6920

Conversation

@yebblies

Copy link
Copy Markdown
Contributor

Print name of failing function, not enclosing function.

https://d.puremagic.com/issues/show_bug.cgi?id=9620

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

diag9620.main.bar is not a pure function, so this error message sounds weird to me.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Doesn't being nested inside a pure function make it pure?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No, currently bar is not marked as pure_. And *currently_ all of local functions (both static and nested) don't inherit pure attribute from enclosing function.

I think this is a bug in Expression::checkPurity(Scope *sc, FuncDeclaration *f). Even the static local function bar has no closest pure parent, but main is incorrectly detected for that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok, but this just changes 'D main' cannot call impure function 'diag9620.foo' to 'diag9620.main.bar' cannot call impure function 'diag9620.foo', which at least an improvement for non-static nested functions.

@yebblies

Copy link
Copy Markdown
Contributor Author

I removed the 'static' on the nested function. If the nested functions aren't (weakly) pure, how can they be called from a pure function and what should we call them?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants