Skip to content

Commit

Permalink
[ruby/prism] Set contains_keywords flag for implicit gets($/, chomp: …
Browse files Browse the repository at this point in the history
…true) method call to handle -l CLI option

ruby/prism@717e41c87d
  • Loading branch information
andrykonchin authored and matzbot committed Oct 7, 2024
1 parent b8c8529 commit 8d35964
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions prism/prism.c
Original file line number Diff line number Diff line change
Expand Up @@ -21906,6 +21906,7 @@ wrap_statements(pm_parser_t *parser, pm_statements_node_t *statements) {
));

pm_arguments_node_arguments_append(arguments, (pm_node_t *) keywords);
pm_node_flag_set((pm_node_t *) arguments, PM_ARGUMENTS_NODE_FLAGS_CONTAINS_KEYWORDS);
}

pm_statements_node_t *wrapped_statements = pm_statements_node_create(parser);
Expand Down
3 changes: 3 additions & 0 deletions test/prism/api/command_line_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ def test_command_line_l
assert_kind_of CallNode, predicate
assert_equal :gets, predicate.name

arguments = predicate.arguments
assert arguments.contains_keywords?

arguments = predicate.arguments.arguments
assert_equal 2, arguments.length
assert_equal :$/, arguments.first.name
Expand Down

0 comments on commit 8d35964

Please sign in to comment.