Skip to content

Commit a27bc27

Browse files
authored
Merge pull request #243 from ruby/schneems/test-prism-versions
Test multiple prism versions in CI + Fix Prism head
2 parents dd1c2bd + ab122c4 commit a27bc27

4 files changed

Lines changed: 30 additions & 11 deletions

File tree

.github/workflows/ci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ jobs:
3232
fail-fast: false
3333
matrix:
3434
ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
35+
prism_version:
36+
- 1.2.0 # Shipped with Ruby 3.4 as default parser https://www.ruby-lang.org/en/news/2024/12/25/ruby-3-4-0-released/
37+
- 1.8.0
38+
- head
39+
env:
40+
PRISM_VERSION: ${{ matrix.prism_version }}
3541
steps:
3642
- name: Checkout code
3743
uses: actions/checkout@v6
@@ -40,6 +46,9 @@ jobs:
4046
with:
4147
ruby-version: ${{ matrix.ruby }}
4248
bundler-cache: true
49+
- name: Use latest prism version (head only)
50+
if: matrix.prism_version == 'head'
51+
run: bundle update prism
4352
- name: test
4453
run: bin/rake test
4554
continue-on-error: ${{ matrix.ruby == 'head' }}

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
## HEAD (unreleased)
22

3+
- Fix: Correctly identify trailing slashes when using Prism > 1.8.0. (https://github.com/ruby/syntax_suggest/pull/243)
4+
- Internal: Add tests to multiple versions of prism
5+
36
## 2.0.2
47

58
- Fix: Separate multiple parser errors by newline. (https://github.com/ruby/syntax_suggest/pull/232)

Gemfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,12 @@ gem "standard"
1212
gem "ruby-prof"
1313

1414
gem "benchmark-ips"
15-
gem "prism"
15+
16+
case ENV["PRISM_VERSION"]&.strip&.downcase
17+
when "head"
18+
gem "prism", github: "ruby/prism"
19+
when nil, ""
20+
gem "prism"
21+
else
22+
gem "prism", ENV["PRISM_VERSION"]
23+
end

lib/syntax_suggest/code_line.rb

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -180,18 +180,17 @@ def ignore_newline_not_beg?
180180
# EOM
181181
# expect(lines.first.trailing_slash?).to eq(true)
182182
#
183-
if SyntaxSuggest.use_prism_parser?
184-
def trailing_slash?
185-
last = @lex.last
186-
last&.type == :on_tstring_end
187-
end
188-
else
189-
def trailing_slash?
190-
last = @lex.last
191-
return false unless last
192-
return false unless last.type == :on_sp
183+
def trailing_slash?
184+
last = @lex.last
193185

186+
# Older versions of prism diverged slightly from Ripper in compatibility mode
187+
case last&.type
188+
when :on_sp
194189
last.token == TRAILING_SLASH
190+
when :on_tstring_end
191+
true
192+
else
193+
false
195194
end
196195
end
197196

0 commit comments

Comments
 (0)