Skip to content

Fails to parse while a in b; end #1771

@tompng

Description

@tompng

Prism fails to parse this code

while a in b; end
until a in b; end
RubyVM::AbstractSyntaxTree.parse('while a in b; end')
=> 
(SCOPE@1:0-1:17
 tbl: [:b]
 args: nil
 body: (WHILE@1:0-1:17 (CASE3@1:6-1:12 (VCALL@1:6-1:7 :a) (IN@1:11-1:12 (LASGN@1:11-1:12 :b nil) (TRUE@1:11-1:12) (FALSE@1:11-1:12))) (BEGIN@1:13-1:13 nil) true))

Prism.parse('while a in b; end').errors
=> 
[#<Prism::ParseError @message="Expected a predicate expression for the `while` statement" @location=#<Prism::Location @start_offset=7 @length=0 start_line=1>>,
 #<Prism::ParseError @message="Cannot parse the expression" @location=#<Prism::Location @start_offset=7 @length=0 start_line=1>>]

if and unless are ok

if a in b; end
unless a in b; end

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions