From 8d359644e7a71c4835b8f385c308571a7a8baf7f Mon Sep 17 00:00:00 2001 From: Andrew Konchin Date: Mon, 7 Oct 2024 15:36:36 +0300 Subject: [PATCH] [ruby/prism] Set contains_keywords flag for implicit gets($/, chomp: true) method call to handle -l CLI option https://github.com/ruby/prism/commit/717e41c87d --- prism/prism.c | 1 + test/prism/api/command_line_test.rb | 3 +++ 2 files changed, 4 insertions(+) diff --git a/prism/prism.c b/prism/prism.c index f19b0392df..e3b1754d39 100644 --- a/prism/prism.c +++ b/prism/prism.c @@ -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); diff --git a/test/prism/api/command_line_test.rb b/test/prism/api/command_line_test.rb index a8c4355152..e53d18703a 100644 --- a/test/prism/api/command_line_test.rb +++ b/test/prism/api/command_line_test.rb @@ -52,6 +52,9 @@ module Prism 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