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

Fix != operator definition #264

Merged

Conversation

stac47
Copy link
Contributor

@stac47 stac47 commented Aug 1, 2024

Problem: If a class declare the not-equal operator !=, the parsing is wrong. For instance, the folowing program:

class A
  def !=(other); end
end

is parsed as if the method ! was a defined with the body expression syntax leading to the following tree:

(program [0, 0] - [3, 0]
  (class [0, 0] - [1, 20]
    name: (constant [0, 6] - [0, 7])
    body: (body_statement [1, 2] - [1, 16]
      (method [1, 2] - [1, 15]
        name: (operator [1, 6] - [1, 7])
        body: (parenthesized_statements [1, 8] - [1, 15]
          (identifier [1, 9] - [1, 14])))))
  (identifier [2, 0] - [2, 3]))

Solution: Declare != as a possible operator definition.

Solves #174

Problem: If a class declare the not-equal operator `!=`, the parsing
is wrong. For instance, the folowing program:

class A
  def !=(other); end
end

is parsed as if the method `!` was a defined with the body expression
syntax leading to the following tree:

(program [0, 0] - [3, 0]
  (class [0, 0] - [1, 20]
    name: (constant [0, 6] - [0, 7])
    body: (body_statement [1, 2] - [1, 16]
      (method [1, 2] - [1, 15]
        name: (operator [1, 6] - [1, 7])
        body: (parenthesized_statements [1, 8] - [1, 15]
          (identifier [1, 9] - [1, 14])))))
  (identifier [2, 0] - [2, 3]))

Solution: Declare `!=` as a possible operator definition.
@stac47 stac47 force-pushed the fix_not_equal_operator_declaration branch from 38147f5 to 2d2887f Compare August 1, 2024 14:48
@amaanq amaanq merged commit 390a15b into tree-sitter:master Aug 17, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants