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

Add support for alias $x $y #1647

Open
sampersand opened this issue Nov 24, 2023 · 2 comments
Open

Add support for alias $x $y #1647

sampersand opened this issue Nov 24, 2023 · 2 comments

Comments

@sampersand
Copy link
Contributor

(Originally a discussion, #1611, I think this is more apt as an issue).

One of the lesser-known facts of ruby is you can also use alias to alias global variables to one another, such as alias $LOAD_PATH $:.

I propose we support this syntax in RBS (it'd be useful for require 'English'). It's very, very niche, but should be supported eventually for completeness.

@sampersand
Copy link
Contributor Author

Shunt to the back of the backlog?

@soutaro
Copy link
Member

soutaro commented Nov 27, 2023

I understand we need it for completeness, but I don't think it's a priority because it's niche...

I'm not against implementing it if someone can send a PR. The outline would be:

  1. Add a syntax AST::Declarations::GlobalAlias or something?
  2. Implement parser
  3. Add a method to resolve type of global like Environment#global_type: (Symbol) -> Types::t?
  4. Need a validation to reject circular definition

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants