Skip to content

RubyVM::InstructionSequence.compile_file uses parse.y instead of prism when called from IRB #1212

Closed

Description

@byroot

Ref: rails/bootsnap#539

I can't explain why it happens.

Reproduction, paste in IRB:

puts RUBY_DESCRIPTION
File.write("/tmp/prism-repro.rb", <<~'RUBY')
  def foo(bars)
    case bars
    in [one, "a" | "b" => two]
      puts "#{one} - #{two}"
    end
  end
RUBY
RubyVM::InstructionSequence.compile_file("/tmp/prism-repro.rb")

Result:

ruby 4.0.2 (2026-03-17 revision d3da9fec82) +PRISM [arm64-darwin25]
(irb):21:in 'RubyVM::InstructionSequence.compile_file': 
/tmp/prism-repro.rb:3: alternative pattern after variable capture (SyntaxError)
  in [one, "a" | "b" => two]
               ^

	from (irb):21:in '<main>'
	from /Users/byroot/.gem/rubies/4.0.2/gems/irb-1.18.0/exe/irb:9:in '<top (required)>'
	from /opt/rubies/4.0.2/lib/ruby/4.0.0/rubygems.rb:304:in 'Kernel#load'
	from /opt/rubies/4.0.2/lib/ruby/4.0.0/rubygems.rb:304:in 'Gem.activate_and_load_bin_path'
	from /Users/byroot/.gem/rubies/4.0.2/bin/irb:25:in '<main>'

This is failing because in Ruby 4.0.2 parse.y has a bug, but the important part here is that this is using parse.y even though the default Ruby parser in that session is supposed to be prism.

Interestingly, RubyVM::InstructionSequence.compile doesn't seem to have this problem.

Activity

  1. byroot commented on May 4, 2026

    @byroot
    MemberAuthor

    Nevermind, seem to be caused by ruby/ruby#16463, I'll ask for a backport.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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