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

Const types as literal types #937

Merged
merged 4 commits into from
Mar 28, 2022
Merged

Const types as literal types #937

merged 4 commits into from
Mar 28, 2022

Conversation

ksss
Copy link
Collaborator

@ksss ksss commented Mar 24, 2022

Sorry for multi fix.
All commit includes testing code.

Currently, const(CDECL node) use the same type resolution as the optional arguments of the method(node_type).
However, most constants are immutable, and it is unnatural to treat them the same as method optional arguments.

For example

E = nil
#=> prototype out `E: untyped?`, But is it useful?

I've modified the case of const and optional arguments to be separated, and const are now attempted to be resolved as literals like method return type.

ksss added 4 commits March 24, 2022 10:44
instead of `node_type`
Because this logic is primarily intended for CDECL.
The `node_type` is used practically only for method arguments.
Change the name to make the difference between `literal_to_type` and `node_type` clearer.
Copy link
Member

@soutaro soutaro left a comment

Choose a reason for hiding this comment

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

👍

@soutaro soutaro merged commit c6325af into ruby:master Mar 28, 2022
@ksss ksss deleted the const-lit branch March 29, 2022 01:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants