Add Crystal::Repl::Value#runtime_type#14156
Conversation
| end | ||
|
|
||
| def runtime_type : Crystal::Type | ||
| if type.is_a?(Crystal::UnionType) |
There was a problem hiding this comment.
issue: This method seems incomplete with handling only union types. What about virtual types?
#runtime_type of Bar.new || Foo.new (with Bar < Foo) should return Bar, not Foo+.
So I think we'll need branches for VirtualType and VirtualMetaclassType.
There was a problem hiding this comment.
Also refer to the class primitive's implementation in the interpreter
There was a problem hiding this comment.
It should definitely match value.class. What would be the preferred way to have a single source of truth for that @HertzDevil ?
There was a problem hiding this comment.
For now just cross-reference the two places in comments, since there are probably even more places than those two that need to agree on the ABI (normal codegen and maybe stdlib)
Crystal::Repl::Value#runtime_type
5ad9a68 to
371b20c
Compare
|
I finally addressed the feedback. I'm not sure the current |
Co-authored-by: Sijawusz Pur Rahnama <sija@sija.pl>
This PR adds
Crystal::Repl::Value#runtime_typeThis can be used to show type information as part of the repl or others clients: eg
1 :: Int32 <: (String | Int32)when instructed (I'm not fully sure about the syntax)