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 all operator symbols #550

Merged

Conversation

ochaochaocha3
Copy link
Contributor

@ochaochaocha3 ochaochaocha3 commented Dec 26, 2020

This pull request adds support for all operator symbols.

RBS v1.0.0 recognizes only :+ or :- as an operator symbol literal, while Ruby syntax allows the use of all redeclarable operators.

シンボル

(snip)

文法:

`:' 識別子
`:' 変数名
`:' 演算子

(snip)

Symbol リテラルに指定できる演算子はメソッドとして再定義できる演算子だけです。演算子式 を参照して下さい。

(Cited from "リテラル (Ruby 2.7.0 リファレンスマニュアル)")

再定義できる演算子(メソッド)

+@, -@ は単項演算子 +, - を表しメソッド定義などではこの記法を利用します。

|  ^  &  <=>  ==  ===  =~  >   >=  <   <=   <<  >>
+  -  *  /    %   **   ~   +@  -@  []  []=  ` ! != !~

(Cited from "演算子式 (Ruby 2.7.0 リファレンスマニュアル)")

This pull request adds regex patterns to support all operator symbol literals. They are tested to be recognized as an RBS::Types::Literal.

@ochaochaocha3 ochaochaocha3 force-pushed the add_support_for_all_operator_symbols branch from ba11602 to f660bae Compare December 30, 2020 06:40
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.

Thanks! 🙏

@soutaro soutaro merged commit aed2a24 into ruby:master Jan 14, 2021
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