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

Prism accepts invalid usage of == with newline that Ruby rejects #3008

Open
Earlopain opened this issue Aug 23, 2024 · 1 comment
Open

Prism accepts invalid usage of == with newline that Ruby rejects #3008

Earlopain opened this issue Aug 23, 2024 · 1 comment
Labels
bug Something isn't working invalid-syntax
Milestone

Comments

@Earlopain
Copy link
Contributor

Example code:

1 if 2 == 3 ==
4

Ruby:

test.rb:1: syntax error, unexpected == (SyntaxError)
1 if 2 == 3 ==
            ^~

Prism:

#<Prism::LexResult:0x00007ba5316a4f80
 @comments=[],
 @data_loc=nil,
 @errors=[],
 @magic_comments=[],
 @source=#<Prism::ASCIISource:0x00007ba531554e78 @offsets=[0, 15, 17], @source="1 if 2 == 3 ==\n4\n", @start_line=1>,
 @value=
  [[INTEGER(1,0)-(1,1)("1"), 2],
   [KEYWORD_IF_MODIFIER(1,2)-(1,4)("if"), 1025],
   [INTEGER(1,5)-(1,6)("2"), 2],
   [EQUAL_EQUAL(1,7)-(1,9)("=="), 1],
   [INTEGER(1,10)-(1,11)("3"), 2],
   [EQUAL_EQUAL(1,12)-(1,14)("=="), 1],
   [IGNORED_NEWLINE(1,14)-(2,0)("\n"), 1],
   [INTEGER(2,0)-(2,1)("4"), 2],
   [NEWLINE(2,1)-(3,0)("\n"), 1],
   [EOF(3,0)-(3,0)(""), 1]],
 @warnings=
  [#<Prism::ParseWarning @type=:void_statement @message="possibly useless use of == in void context" @location=#<Prism::Location @start_offset=0 @length=16 start_line=1> @level=:verbose>]>
@Earlopain

This comment was marked as off-topic.

@kddnewton kddnewton added bug Something isn't working invalid-syntax labels Aug 23, 2024
@kddnewton kddnewton added this to the Long-term milestone Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working invalid-syntax
Projects
None yet
Development

No branches or pull requests

2 participants