nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: ruby/prism
Pull request #2579 (2024-03-12 14:04:18)

Fix a token incompatibility for `Prism::Translation::Parser::Lexer`
This PR fixes a token incompatibility between Parser gem and `Prism::Translation::Parser` for beginless range:

## Parser gem (Expected)

Returns `tBDOT2` token:

```console
$ bundle exec ruby -Ilib -rparser/ruby33 -ve \
'buf = Parser::Source::Buffer.new("example.rb"); buf.source = "..42"; p Parser::Ruby33.new.tokenize(buf)[2]'
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]
[[:tBDOT2, ["..", #<Parser::Source::Range example.rb 0...2>]], [:tINTEGER, [42, #<Parser::Source::Range example.rb 2...4>]]]
```

## `Prism::Translation::Parser` (Actual)

Previously, the parser returned `tDOT2` token when parsing the following:

```console
$ bundle exec ruby -Ilib -rprism -rprism/translation/parser33 -ve \
'buf = Parser::Source::Buffer.new("example.rb"); buf.source = "..42"; p Prism::Translation::Parser33.new.tokenize(buf)[2]'
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]
[[:tDOT2, ["..", #<Parser::Source::Range example.rb 0...2>]], [:tINTEGER, [42, #<Parser::Source::Range example.rb 2...4>]]]
```

After the update, the parser now returns `tBDOT2` token for the same input:

```console
$ bundle exec ruby -Ilib -rprism -rprism/translation/parser33 -ve \
'buf = Parser::Source::Buffer.new("example.rb"); buf.source = "..42"; p Prism::Translation::Parser33.new.tokenize(buf)[2]'
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]
[[:tBDOT2, ["..", #<Parser::Source::Range example.rb 0...2>]], [:tINTEGER, [42, #<Parser::Source::Range example.rb 2...4>]]]
```

This correction enables the restoration of `endless_range_in_conditional.txt` as a test case.


Patch:
diff --git a/lib/prism/translation/parser/lexer.rb b/lib/prism/translation/parser/lexer.rb
index 8bb30845..590adef3 100644
--- a/lib/prism/translation/parser/lexer.rb
+++ b/lib/prism/translation/parser/lexer.rb
@@ -167,7 +167,7 @@ module Prism
           TILDE: :tTILDE,
           UAMPERSAND: :tAMPER,
           UCOLON_COLON: :tCOLON3,
-          UDOT_DOT: :tDOT2,
+          UDOT_DOT: :tBDOT2,
           UDOT_DOT_DOT: :tBDOT3,
           UMINUS: :tUMINUS,
           UMINUS_NUM: :tUNARY_NUM,


Test patch:
diff --git a/test/prism/parser_test.rb b/test/prism/parser_test.rb
index 118b7322..061e4b85 100644
--- a/test/prism/parser_test.rb
+++ b/test/prism/parser_test.rb
@@ -73,7 +73,6 @@ module Prism
     skip_tokens = [
       "comments.txt",
       "constants.txt",
-      "endless_range_in_conditional.txt",
       "heredoc_with_comment.txt",
       "heredoc_with_escaped_newline_at_start.txt",
       "heredocs_leading_whitespace.txt",
Repository: ruby/prism
Pull request #2886 (2024-06-12 14:49:43)

Small amount of parser translation work


Patch:
diff --git a/lib/prism/translation/parser/lexer.rb b/lib/prism/translation/parser/lexer.rb
index 9d7caae0..8191bd19 100644
--- a/lib/prism/translation/parser/lexer.rb
+++ b/lib/prism/translation/parser/lexer.rb
@@ -339,7 +339,7 @@ module Prism
                 location = Range.new(source_buffer, offset_cache[token.location.start_offset], offset_cache[token.location.start_offset + 1])
               end
             when :tSYMBEG
-              if (next_token = lexed[index][0]) && next_token.type != :STRING_CONTENT && next_token.type != :EMBEXPR_BEGIN && next_token.type != :EMBVAR
+              if (next_token = lexed[index][0]) && next_token.type != :STRING_CONTENT && next_token.type != :EMBEXPR_BEGIN && next_token.type != :EMBVAR && next_token.type != :STRING_END
                 next_location = token.location.join(next_token.location)
                 type = :tSYMBOL
                 value = next_token.value


Test patch:
diff --git a/test/prism/ruby/parser_test.rb b/test/prism/ruby/parser_test.rb
index a5cf919a..b60ccf93 100644
--- a/test/prism/ruby/parser_test.rb
+++ b/test/prism/ruby/parser_test.rb
@@ -130,7 +130,6 @@ module Prism
       "seattlerb/parse_line_heredoc.txt",
       "seattlerb/parse_line_multiline_str_literal_n.txt",
       "seattlerb/parse_line_str_with_newline_escape.txt",
-      "seattlerb/pct_Q_backslash_nl.txt",
       "seattlerb/pct_w_heredoc_interp_nested.txt",
       "seattlerb/qsymbols_empty_space.txt",
       "seattlerb/qw_escape_term.txt",
@@ -144,7 +143,6 @@ module Prism
       "seattlerb/str_evstr_escape.txt",
       "seattlerb/str_newline_hash_line_number.txt",
       "seattlerb/str_single_newline.txt",
-      "seattlerb/symbol_empty.txt",
       "seattlerb/symbols_empty_space.txt",
       "seattlerb/TestRubyParserShared.txt",
       "unparser/corpus/literal/assignment.txt",
@@ -209,7 +207,15 @@ module Prism
         end
 
         assert_equal expected_ast, actual_ast, -> { assert_equal_asts_message(expected_ast, actual_ast) }
-        assert_equal_tokens(expected_tokens, actual_tokens) if compare_tokens
+
+        begin
+          assert_equal_tokens(expected_tokens, actual_tokens)
+        rescue Test::Unit::AssertionFailedError
+          raise if compare_tokens
+        else
+          puts "#{fixture.path} is now passing" if !compare_tokens
+        end
+
         assert_equal_comments(expected_comments, actual_comments) if compare_comments
       elsif compare_asts
         assert_equal expected_ast, actual_ast, -> { assert_equal_asts_message(expected_ast, actual_ast) }
@@ -247,7 +253,7 @@ module Prism
 
         while expected_index < expected_tokens.length
           expected_token = expected_tokens[expected_index]
-          actual_token = actual_tokens[actual_index]
+          actual_token = actual_tokens.fetch(actual_index, [])
 
           expected_index += 1
           actual_index += 1
Repository: ruby/prism
Pull request #3021 (2024-08-28 21:00:03)

Multi-splat flag for arguments


Patch:
diff --git a/config.yml b/config.yml
index dc19295c..b7c67381 100644
--- a/config.yml
+++ b/config.yml
@@ -653,6 +653,8 @@ flags:
         comment: "if arguments contain keyword splat"
       - name: CONTAINS_SPLAT
         comment: "if arguments contain splat"
+      - name: CONTAINS_MULTIPLE_SPLATS
+        comment: "if arguments contain multiple splats"
     comment: Flags for arguments nodes.
   - name: ArrayNodeFlags
     values:
diff --git a/src/prism.c b/src/prism.c
index 28bd8d0d..4edb57ad 100644
--- a/src/prism.c
+++ b/src/prism.c
@@ -2065,7 +2065,11 @@ pm_arguments_node_arguments_append(pm_arguments_node_t *node, pm_node_t *argumen
     pm_node_list_append(&node->arguments, argument);
 
     if (PM_NODE_TYPE_P(argument, PM_SPLAT_NODE)) {
-        pm_node_flag_set((pm_node_t *) node, PM_ARGUMENTS_NODE_FLAGS_CONTAINS_SPLAT);
+        if (PM_NODE_FLAG_P(node, PM_ARGUMENTS_NODE_FLAGS_CONTAINS_SPLAT)) {
+            pm_node_flag_set((pm_node_t *) node, PM_ARGUMENTS_NODE_FLAGS_CONTAINS_MULTIPLE_SPLATS);
+        } else {
+            pm_node_flag_set((pm_node_t *) node, PM_ARGUMENTS_NODE_FLAGS_CONTAINS_SPLAT);
+        }
     }
 }
 


Test patch:
diff --git a/test/prism/snapshots/unparser/corpus/literal/send.txt b/test/prism/snapshots/unparser/corpus/literal/send.txt
index 9f9eeb13..4800b4e2 100644
--- a/test/prism/snapshots/unparser/corpus/literal/send.txt
+++ b/test/prism/snapshots/unparser/corpus/literal/send.txt
@@ -1123,7 +1123,7 @@
         │   ├── opening_loc: (59,7)-(59,8) = "("
         │   ├── arguments:
         │   │   @ ArgumentsNode (location: (59,8)-(59,25))
-        │   │   ├── flags: contains_splat
+        │   │   ├── flags: contains_splat, contains_multiple_splats
         │   │   └── arguments: (length: 3)
         │   │       ├── @ SplatNode (location: (59,8)-(59,13))
         │   │       │   ├── flags: ∅
Repository: py-cov-action/python-coverage-comment-action
Pull request #424 (2024-06-06 11:05:10)

Improve checks on github.ref fields
This PR arises from the problem of having `"pull"` substring inside your branch name.

In particular, having a branch name like `ISSUE-XXX/task/enable-pull-lorem-ipsum`  causes a crash in the action since  the if inside `GITHUB_PR_NUMBER` property wrongly assumes that `github.ref` refers to a PR, and tries to cast to integer the PR number. 

Goal of this PR is to make the check a bit stronger, for both `GITHUB_PR_NUMBER` and `GITHUB_BRANCH_NAME` (since it's easier to incur in same problem with a tags that contains `"heads"` substring inside it)  checking `github.ref` head rather than randomly checking that a word is inside it.


Patch:
diff --git a/coverage_comment/settings.py b/coverage_comment/settings.py
index ed0c27c..5d4360b 100644
--- a/coverage_comment/settings.py
+++ b/coverage_comment/settings.py
@@ -125,14 +125,14 @@ class Config:
     @property
     def GITHUB_PR_NUMBER(self) -> int | None:
         # "refs/pull/2/merge"
-        if "pull" in self.GITHUB_REF:
+        if self.GITHUB_REF.startswith("refs/pull"):
             return int(self.GITHUB_REF.split("/")[2])
         return None
 
     @property
     def GITHUB_BRANCH_NAME(self) -> str | None:
         # "refs/heads/my_branch_name"
-        if "heads" in self.GITHUB_REF:
+        if self.GITHUB_REF.startswith("refs/heads"):
             return self.GITHUB_REF.split("/", 2)[2]
         return None
 


Test patch:
diff --git a/tests/unit/test_settings.py b/tests/unit/test_settings.py
index a335827..b283d99 100644
--- a/tests/unit/test_settings.py
+++ b/tests/unit/test_settings.py
@@ -127,6 +127,8 @@ def config():
     "github_ref, github_pr_number",
     [
         ("foo", None),
+        ("refs/heads/branch-with-pull", None),
+        ("refs/tags/tag-with-pull", None),
         ("refs/pull/2/merge", 2),
     ],
 )
@@ -138,6 +140,8 @@ def test_config__GITHUB_PR_NUMBER(config, github_ref, github_pr_number):
     "github_ref, github_branch_name",
     [
         ("refs/pull/2/merge", None),
+        ("refs/pull/2/head", None),
+        ("refs/tags/tag-with-heads", None),
         ("refs/heads/a/b", "a/b"),
     ],
 )