-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fix: interpreter handles self in inlined method with arguments
#16307
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
Fix: interpreter handles self in inlined method with arguments
#16307
Conversation
self in inlined method with arguments
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.
Sounds good. It makes sense to handle the args first, and then leave self on the stack, instead of handling args last and have them maybe mess with the stack.
|
Here's the chat history with chain of thoughts to help understand the fix:
Chao Yang
object.cr This repo contains code for crystal lang's compiler which is also an interpreter. The interpreter should behave the same as executing the compiled binary. Read and modify relevant code files to fix an error that only happens when interpreting a program while working fine with compiled binary. It incorrectly returns the method parameter as self, as comparison it works if not passing param to the not_nil! This suggests that something's wrong with stack operation or method scope.
|
|
Calling discard_value in inlined self is causing a stack imbalance. While we have a workaround, the root cause is still a mystery. The Gemini AI is also refusing to dig deeper into the problem, which feels like 'cheating' to me. |
|
The full chat log ain't very useful. Only the following bit is valuable as it explains what was the issue and why it implemented the fix. With some edit/markdown style to improve readability it could have become the PR description:
|
|
Both patches (here and #16303) are interesting and welcomed. I'm impressed that an AI could pinpoint the actual issues to be honest 👌 Now, when pushing a PR, one should try to understand what the AI did so they can explain it back (that's the ideal situation) and to at least extract the most interesting bit out of the chat log, as I did above for example. Here, it was sufficient (discard args before pushing self 👍), in #16303 it needed additional knowledge to validate the issue (harder) which @HertzDevil provided. If unsure, I can only encourage to first comment on the original issue what the AI identified (only the conclusion, not the full chat log, please 🙇) and the potential patch. |
|
@ysbaddaden It usually doesn't work with a single try with AI, I think it's still valuable to provide the AI prompt(user's initial input) to help others use it more effectively. Specifically, in this prompt, the key is below:
I was also shocked by the potential capabilities of AI, but it still needs humans to validate the results. |
Fixes #16210
@ysbaddaden @straight-shoota So this fix was also generated by google gemini AI in vscode.
I actually tried github copilot first but failed.