github / github/codeql

Ruby: &[SPACE][identifier] syntax breaks Ruby parsing

Open
#21,801 1 comment 0 reactions 0 assignees View on GitHub
question
Dominant language
CodeQL
Stars
10.1k
Forks
2.1k
Avg merge
2d 15h
Merged PRs (30d)
141

Description

CodeQL's Ruby breaks parsing breaks for the following code:

```ruby
sorted_array = array.sort(& custom_sorts[params[:sortby]])
```

I understand that the following *should* be how this is written, but sometimes people put weird syntax in and it shouldn't break a whole file being parsed:

```ruby
sorted_array = array.sort(&custom_sorts[params[:sortby]])
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the Ruby parser failure with the two sort examples in the issue, focusing on the space between `&` and the identifier. Trace the parser entry point that handles this syntax and verify that both forms are accepted without preventing the rest of the file from being parsed.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.