Add method! and public_send! for OpenStruct warnings#7524
Draft
headius wants to merge 1 commit intojruby:masterfrom
Draft
Add method! and public_send! for OpenStruct warnings#7524headius wants to merge 1 commit intojruby:masterfrom
headius wants to merge 1 commit intojruby:masterfrom
Conversation
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.
Member
Author
|
Still not sure I like this solution, so bumping. |
Member
Author
|
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
This file contains hidden or 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
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.