Skip to content

Commit 6c7b70c

Browse files
authored
Merge pull request ruby#3494 from Earlopain/parser-translator-backwards-compat
2 parents 4b389d0 + 66b0162 commit 6c7b70c

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

lib/prism/translation/parser/compiler.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,17 @@ def visit_it_local_variable_read_node(node)
11571157
# -> { it }
11581158
# ^^^^^^^^^
11591159
def visit_it_parameters_node(node)
1160-
builder.itarg
1160+
# FIXME: The builder _should_ always be a subclass of the prism builder.
1161+
# Currently RuboCop passes in its own builder that always inherits from the
1162+
# parser builder (which is lacking the `itarg` method). Once rubocop-ast
1163+
# opts in to use the custom prism builder a warning can be emitted when
1164+
# it is not the expected class, and eventually raise.
1165+
# https://github.com/rubocop/rubocop-ast/pull/354
1166+
if builder.is_a?(Translation::Parser::Builder)
1167+
builder.itarg
1168+
else
1169+
builder.args(nil, [], nil, false)
1170+
end
11611171
end
11621172

11631173
# foo(bar: baz)

0 commit comments

Comments
 (0)