Skip to content

Robust version of Prism.parse(code, version: 'current') #3885

@tompng

Description

@tompng

In IRB, it's better to parse ruby code with current ruby version for usability, but doesn't strictly require current version.
It basically work except for few edge cases: Error tokens (valid in latest) won't be rendered RED. (example: "if a\n&&b\nend")

Parsing with Prism.parse(code, version: RUBY_VERSION >= '3.3' ? '3.3' : 'current') is not enough.
Lower bound(3.3) may change in the future, RUBY_VERSION may exceed upper bound(3.4 (prism-1.6) or 4.1 (prism >= 1.7)) that may block updating ruby version in a rails app.

It would be helpful if there is an easy way to use current version robustly (like Prism.parse(code, version: 'nearest' or 'closest')), or a way to get supported version range.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions