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

Refer to T.class as "metaclass" in error messages, not "class" #11378

Merged

Conversation

HertzDevil
Copy link
Contributor

Metaclasses are special in that they are classes but inherit from Value other than Reference. This produces some nonsensical error messages:

class Foo
end

alias A = Foo.class

class B < A # Error: Foo.class is not a class, it's a class
end

This PR makes it so that they are reported as "metaclass" instead. Doing so also fixes an internal compiler error:

class Foo
end

instance_sizeof(Foo.class) # BUG: called llvm_struct_type for Foo.class

@HertzDevil HertzDevil added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler labels Oct 28, 2021
Copy link
Member

@sdogruyol sdogruyol 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 @HertzDevil 🙏

@straight-shoota straight-shoota added this to the 1.3.0 milestone Nov 26, 2021
@straight-shoota straight-shoota merged commit 90d8941 into crystal-lang:master Nov 29, 2021
@HertzDevil HertzDevil deleted the bug/metaclass-type-desc branch November 29, 2021 15:10
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants