Skip to content

Consider removing Prism::Translation::Parser35 alias for Sorbet compatibility #3833

@bflad

Description

@bflad

When running Sorbet type checking (srb tc), the definition of Prism::Translation::Parser35 in lib/prism/translation/parser35.rb when converted to RBI:

# source://prism//lib/prism/translation/parser35.rb#6
Prism::Translation::Parser35 = Prism::Translation::Parser40

class Prism::Translation::Parser35 < Prism::Translation::Parser; end

Causes errors:

sorbet/rbi/gems/prism@1.7.0.rbi:34454: Cannot initialize the class `Parser35` by constant assignment https://srb.help/4022
       34454 |Prism::Translation::Parser35 = Prism::Translation::Parser40
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    sorbet/rbi/gems/prism@1.7.0.rbi:34456: Previously defined as a class here
       34456 |class Prism::Translation::Parser35 < Prism::Translation::Parser; end
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  Note:
    Sorbet does not allow treating constant assignments as class or module definitions,
    even if the initializer computes a `Module` object at runtime. See the docs for more.
Errors: 1

Please note that my work is for a code generation company that supports customers that opt into using Sorbet in their Ruby projects. This seems like an issue that Sorbet should resolve somehow, however given that Ruby 3.5 does not exist, removing the alias theoretically would also fix this issue. For now, we will setup Sorbet to ignore this error as a workaround.

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