Skip to content
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 codegen when instantiating class methods of typedefs #11636

Conversation

HertzDevil
Copy link
Contributor

@HertzDevil HertzDevil commented Dec 22, 2021

Adds a %self parameter to the generated LLVM function if a method's receiver is of type T.class where T is a typedef of a generic instance (almost always Void*). Fixes #8544.

It appears the interpreter also uses Crystal::Type#passed_as_self?. I don't know what effects this PR would have on it.

@HertzDevil HertzDevil added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:codegen labels Dec 22, 2021
@beta-ziliani
Copy link
Member

I'll wait for @asterite 's input, but to me this patch seems like the right way to solve the passed_as_self method. I'd be surprised if the interpreter expects a different thing.

Copy link
Member

@asterite asterite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@straight-shoota straight-shoota added this to the 1.3.0 milestone Jan 1, 2022
@straight-shoota straight-shoota merged commit e2da380 into crystal-lang:master Jan 3, 2022
@HertzDevil HertzDevil deleted the bug/typedef-metaclass-pass-self branch January 3, 2022 11:03
rdp pushed a commit to rdp/crystal that referenced this pull request Jan 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:codegen
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compiler crash with to_unsafe and C type
4 participants