-
Notifications
You must be signed in to change notification settings - Fork 914
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
Add method! and public_send! for OpenStruct warnings #7524
Draft
headius
wants to merge
1
commit into
jruby:master
Choose a base branch
from
headius:suppress_ostruct_warnings
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
Due to these methods now accessing the caller's scope (for refinements) they now warn when being aliased to another name. We suppress the warning when the target name has a superset of client frame reads, so this patch adds `method!` and `public_send!` with SCOPE read. This is not ideal, since any future method gaining frame fields will need to have the same treatment, and other similar methods are being skipped by OpenStruct (by our request). However this suppresses the warning for now and we can work on a long-term option.
Still not sure I like this solution, so bumping. |
These warnings are now only displayed in verbose mode, so we can reevaluate whether this is still necessary in 9.5. |
headius
added a commit
to headius/jruby
that referenced
this pull request
Apr 22, 2024
The ostruct library aliases all methods from Object/Kernel with a bang suffix ("!") to allow them to be callable even though the OpenStruct should support them as field names. Because we use record these names in a table of known frame-aware methods, we have typically warned when aliasing them. This rarely comes up, since aliasing usually is accompanied by wrapping, which breaks their behavior on all implementations, but this aliasing in ostruct is unusual and pervasive, leading to issues like jruby#8200. This patch assumes we're going to have issues with ostruct forever and eagerly adds the "!" names alongside the regular names for all method names that match /[a-z_]/, so taht existing methods and future methods will behavior properly and not warn when aliased. It adds a small amount to startup, since these method names must be added twice, but there are not many such names in the system. Fixes jruby#8200 Replaces jruby#7524
headius
added a commit
to headius/jruby
that referenced
this pull request
Apr 22, 2024
The ostruct library aliases all methods from Object/Kernel with a bang suffix ("!") to allow them to be callable even though the OpenStruct should support them as field names. Because we use record these names in a table of known frame-aware methods, we have typically warned when aliasing them. This rarely comes up, since aliasing usually is accompanied by wrapping, which breaks their behavior on all implementations, but this aliasing in ostruct is unusual and pervasive, leading to issues like jruby#8200. This patch assumes we're going to have issues with ostruct forever and eagerly adds the "!" names alongside the regular names for all method names that match /[a-z_]/, so taht existing methods and future methods will behavior properly and not warn when aliased. It adds a small amount to startup, since these method names must be added twice, but there are not many such names in the system. Fixes jruby#8200 Replaces jruby#7524
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Due to these methods now accessing the caller's scope (for refinements) they now warn when being aliased to another name. We suppress the warning when the target name has a superset of client frame reads, so this patch adds
method!
andpublic_send!
with SCOPE read.This is not ideal, since any future method gaining frame fields will need to have the same treatment, and other similar methods are being skipped by OpenStruct (by our request). However this suppresses the warning for now and we can work on a long-term option.