Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@bbuchalter
Last active May 25, 2022 11:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bbuchalter/4688402ef35c585ba4c41151ac07b95c to your computer and use it in GitHub Desktop.
Save bbuchalter/4688402ef35c585ba4c41151ac07b95c to your computer and use it in GitHub Desktop.
Ruby can only parse 2498 case statement branches
case_statements = 10000
program = <<-RUBY
case(ARGV[1])
#{case_statements.times.map { |n| "when #{n+1} \n puts #{n+1}"}.join("\n")}
end
RUBY
File.write('test.rb', program)
puts "RUBY_VERSION=#{RUBY_VERSION}"
puts system('ruby test.rb')
=begin
$ ruby case_test.rb
RUBY_VERSION=3.1.2
test.rb:4997: nesting too deep
puts 2498
false
=end
@bbuchalter
Copy link
Author

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