Last active
May 25, 2022 11:31
-
-
Save bbuchalter/4688402ef35c585ba4c41151ac07b95c to your computer and use it in GitHub Desktop.
Ruby can only parse 2498 case statement branches
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/ruby/ruby/blob/v3_1_2/parse.y#L109-L111