Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Fix Ruby build on HEAD #337

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

Merged
merged 1 commit into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/syntax_tree/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6767,6 +6767,7 @@ def format(q)
q.group do
q.text(keyword)
q.nest(keyword.length) { q.format(pattern) }
q.text(" then") if pattern.is_a?(RangeNode) && pattern.right.nil?

unless statements.empty?
q.indent do
Expand Down
9 changes: 8 additions & 1 deletion lib/syntax_tree/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2132,13 +2132,20 @@ def on_in(pattern, statements, consequent)
ending = consequent || consume_keyword(:end)

statements_start = pattern
if (token = find_keyword(:then))
if (token = find_keyword_between(:then, pattern, statements))
tokens.delete(token)
statements_start = token
end

start_char =
find_next_statement_start((token || statements_start).location.end_char)

# Ripper ignores parentheses on patterns, so we need to do the same in
# order to attach comments correctly to the pattern.
if source[start_char] == ")"
start_char = find_next_statement_start(start_char + 1)
end

statements.bind(
self,
start_char,
Expand Down