Skip to content

Commit

Permalink
[prism/compiler] end_cursor should never be NULL
Browse files Browse the repository at this point in the history
This fixes a failed assertion reported to SimpleCov

simplecov-ruby/simplecov#1113

The smallest repro I can make consists of 2 files

test.rb containing the following code:

```
require 'coverage'
Coverage.start(branches: true)
require_relative 'broken.rb'
```

and `broken.rb` containing this

```
@foo&.bar(@baz)
```
  • Loading branch information
eightbitraptor committed Nov 20, 2024
1 parent 811dfa7 commit a9788d4
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions prism_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -3630,6 +3630,7 @@ pm_compile_call(rb_iseq_t *iseq, const pm_call_node_t *call_node, LINK_ANCHOR *c
const uint8_t *end_cursor = cursors[0];
end_cursor = (end_cursor == NULL || cursors[1] == NULL) ? cursors[1] : (end_cursor > cursors[1] ? end_cursor : cursors[1]);
end_cursor = (end_cursor == NULL || cursors[2] == NULL) ? cursors[2] : (end_cursor > cursors[2] ? end_cursor : cursors[2]);
if (!end_cursor) end_cursor = scope_node->parser->newline_list.start;

const pm_line_column_t start_location = PM_NODE_START_LINE_COLUMN(scope_node->parser, call_node);
const pm_line_column_t end_location = pm_newline_list_line_column(&scope_node->parser->newline_list, end_cursor, scope_node->parser->start_line);
Expand Down

0 comments on commit a9788d4

Please sign in to comment.