-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
detect errors in generated function declarations early #18605
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added by @JeffBezanson in b43c5e0 - presumably this was needed for something?
I hate to backport new restrictions, even if it's just an earlier error on code that may be invalid. Will have to see how many packages are actually doing this. What's allowed in generated functions is starting to become a pretty restrictive subset of the language, and I don't think people have been aware of that or writing them that way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At some point, we likely may want to reintroduce this, but right now it gets handled incorrectly by the runtime system and will likely require not-backportable changes to fix.
It's not "starting to become" because it's really not a new restriction, it's just better at enforcing correctness up-front now. On the other hand, the fix for #265 will add significant new restrictions to them, although it shouldn't affect anyone who's been fully observant of their definition.
That's too bad, but the manual does repeat several times that "you should /never/ write a generated function with side effects" [emphasis original] http://docs.julialang.org/en/latest/manual/metaprogramming/#generated-functions (unfortunately interspersed with various buggy examples). I can repeat it a few more times, but I consider it better just to enforce the restrictions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we please fix and elaborate on the docs while we're at it then? Most people likely don't think of using closures or comprehensions as having side effects in this way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mixed into the same PR or on its own?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
either, as long as it gets done promptly. considering this is newly enforced, it should probably be documented here though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's not reasonable to consider a generated function with a closure to have side effects --- the side effects there are in our implementation, not in the user's code.
For backporting, it doesn't matter how "new restriction" is defined. All that matters is whether code can break.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I wouldn't have made this an error if that code wasn't already broken, so that this was just adding a clearer error than "segfault", corruption of precompiled files, or other errors in which method gets called.
I look forward to having anonymous functions again, so that they are uniquely defined by content rather than by name.