-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fix interpreter when inlining pure InstanceVar virtual def and only one concrete subclass exists
#16303
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
base: master
Are you sure you want to change the base?
Conversation
…ct class when run with interpreter
ysbaddaden
left a comment
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.
I don't enough of the compiler internals to know whether the solution is correct, but CI is happy and the bug seems fixed 👍
InstanceVar virtual def and only one concrete subclass exists
|
In compiled code, When a def's body is exactly an struct Foo
property x = 1
property y = 2
end
class Bar
@foo = Foo.new
def foo
@foo
end
def foo2
foo # not an `InstanceVar` node
end
end
bar = Bar.new
bar.foo.x = 3 # this `#foo` call is inlined
bar # => #<Bar:0x1e65ad36fc0 @foo=Foo(@x=3, @y=2)>
bar.foo2.x = 4 # this `#foo2` call is not inlined
bar # => #<Bar:0x1e65ad36fc0 @foo=Foo(@x=3, @y=2)>The interpreter does the same in order to preserve the above semantics, but it fails to consider the case where the call ( Calls with an explicit receiver are unaffected, as they trigger the Normally, the onus of providing this description of the problem and solution is on the PR submitter though, so that even reviewers with less knowledge of the compiler's code could be confident that the PR is not merely addressing a symptom while masking the underlying cause, nor throwing code at the wall and seeing what sticks. Using a bot does not grant the free pass of saying that a fix "seems" to be reasonable. |
Oh, now I understand why |
Co-authored-by: Quinton Miller <[email protected]>
|
@HertzDevil I was just wondering if AI could help this project or not, so I gave it a try. Below is the chat history including the chain of thoughts, I hope it helps clarifying things a bit. And I think it might be helpful to use AI for analyzing bugs. @straight-shoota What's the policy regarding code changes made by AI? Is it prohibited or accepted with chat history?
|
|
For me, it's not relevant how a patch came together. If you rolled a dice, or trained a monkey to do it, that's all fine as long as you have the rights to license the code under our license terms. The contribution guide does not have any specific rules regarding AI use. All the general rules apply, of course. For example: describe reasons and result of the change in the pull request comment. |
|
OK, so it's better to provide summary of AI analysis to the github issue first before creating a PR. And it looks like the AI is helpful at finding root causes of bugs. |
fixes #16278
@ysbaddaden @straight-shoota This fix was generated by google gemini AI via Gemini Code Assist plugin in vscode.
I created this PR to see if the fix would cause any other test to fail.
So please review this carefully.
It seems like this fix is reasonable as now both if branches pass down the
target_def.owner.