Skip to content

Upgrade ruby-prism to 2.0, and parse Ruby 4.0's syntax - #88

Merged
dduugg merged 1 commit into
mainfrom
ruby-prism-2
Nov 2, 2026
Merged

dduugg merged 1 commit into
mainfrom
ruby-prism-2

Conversation

@dduugg

@dduugg dduugg commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

#85 fails to build because ruby-prism 2.0.0 changed its API. This takes the ruby-prism part of #85 and makes pks compile against it, so that Dependabot can rebase #85 onto just its dua-core and jsonschema updates, which build as they are.

API changes

  • Location::start_offset/end_offset are now start/end, returning u32.
  • Diagnostic::message returns &[u8] and no longer panics on a message that isn't UTF-8. pks no longer catches that panic or quiets the panic hook around it, and the unit test of the hook goes. pks still says "its message isn't UTF-8" for such a message, which test_check_warns_about_an_error_whose_message_isnt_utf_8 covers.

Parsing Ruby 4.0's syntax

With no options, Prism 2.0 parses the syntax of Ruby 4.1, which isn't released until December 25. Ruby 4.0, the newest release, disagrees with it on three constructs:

Ruby Prism 1.9, the default (pks on main) Prism 2.0, the default Ruby 4.0.9 Prism 2.0, CRuby3_5 (this PR)
def a(&nil) syntax error accepted syntax error syntax error
def b(x,) syntax error accepted syntax error syntax error
END { break } accepted syntax error accepted accepted

So pks now parses with Version::CRuby3_5, the crate's name for 4.0, and test_check_reads_ruby_4_0_syntax checks all three with both parsers. With Version::Latest that test fails. The version will need raising once 4.1 is released.

No more libclang

ruby-prism-sys 2.0 ships its bindings pregenerated, so a build no longer runs bindgen, and Cargo.lock loses ten packages, bindgen and clang-sys among them. INSTALLATION.md, the Unreleased changelog and a comment in ci.yml now ask only for a C compiler.

The lock has ruby-prism-sys 2.0.0, where #85 has 2.1.0, since 2.1.0 came out on October 28, inside Dependabot's 7-day cooldown.

Testing

  • cargo test --locked: 398 pass. cargo clippy --all-targets --all-features and cargo fmt --check are clean, and cargo audit passes.
  • I ran a main build and this branch over every fixture in tests/fixtures, with check, list-definitions and list-references, each with and without --experimental-parser. That was 216 runs, and the output was the same in all of them. The one fixture that panics, app_with_monkey_patches without --experimental-parser, panics the same way on main: it's the TODO in constant_resolver.rs about two definitions of one constant.

Dependabot's #85 raises ruby-prism to 2.0.0, which pks doesn't compile
with: `Location` has `start` and `end` in place of `start_offset` and
`end_offset`, and `Diagnostic::message` returns bytes. This takes the
ruby-prism part of #85, so that Dependabot can rebase #85 onto just its
dua-core and jsonschema updates.

`message` no longer panics on a message that isn't UTF-8, so pks no
longer catches that panic or quiets the panic hook while it does, and
the unit test of the hook goes. pks still says "its message isn't
UTF-8" for such a message.

Without options, Prism 2.0 parses the syntax of Ruby 4.1, which isn't
released until December 25. It accepts `&nil` and a trailing comma in
a method's parameters, and rejects `break` in an `END` block, where
Ruby 4.0 does the reverse. pks now asks Prism for Ruby 4.0's syntax
(`Version::CRuby3_5`, as the crate names it), and a test checks all
three. Prism 1.9 also defaulted to 4.1, but its 4.1 read these as 4.0
does, so pks reads them as it did before. The version will need
raising once Ruby 4.1 is released.

ruby-prism-sys 2.0 ships its bindings pregenerated, so a build no
longer runs bindgen or needs libclang, and Cargo.lock loses ten
packages, bindgen and clang-sys among them. INSTALLATION.md, the
changelog and a comment in ci.yml now ask only for a C compiler.

The lock has ruby-prism-sys 2.0.0, where #85 has 2.1.0, since 2.1.0
came out on October 28, inside Dependabot's 7-day cooldown.
@dduugg
dduugg requested a review from a team as a code owner November 2, 2026 21:06
@github-project-automation github-project-automation Bot moved this to Triage in Modularity Nov 2, 2026
@dduugg
dduugg merged commit da27880 into main Nov 2, 2026
22 checks passed
@dduugg
dduugg deleted the ruby-prism-2 branch November 2, 2026 21:12
@github-project-automation github-project-automation Bot moved this from Triage to Done in Modularity Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant