From: "nagachika (Tomoyuki Chikanaga) via ruby-core" Date: 2024-07-15T00:50:33+00:00 Subject: [ruby-core:118592] [Ruby master Bug#20296] Complex(:sym, exception: false) generate exception with weird timing Issue #20296 has been updated by nagachika (Tomoyuki Chikanaga). Backport changed from 3.0: REQUIRED, 3.1: REQUIRED, 3.2: REQUIRED, 3.3: DONE to 3.0: REQUIRED, 3.1: REQUIRED, 3.2: DONE, 3.3: DONE ruby_3_2 commit:90f4c5dc73af3fff76500dd4223792a6d9f58636 merged revision(s) commit:dc146babf47a84bbd1f176d766637d4a40327019, commit:f23d5028059078a346efc977287b669d494a5a3f, commit:a0f7de814ae5c299d6ce99bed5fb308a05d50ba0. ---------------------------------------- Bug #20296: Complex(:sym, exception: false) generate exception with weird timing https://bugs.ruby-lang.org/issues/20296#change-109119 * Author: MaxLap (Maxime Lapointe) * Status: Closed * ruby -v: 3.3.0 * Backport: 3.0: REQUIRED, 3.1: REQUIRED, 3.2: DONE, 3.3: DONE ---------------------------------------- Happens in Ruby 3.2.2, 3.2.3 and 3.3.0 (didn't test others). Add this to a file and execute it as-is: ``` 3.times { Complex(:sym, exception: false) } puts "hi" ``` The output will be: ``` $ ruby local2.rb hi local2.rb:1:in `Complex': can't convert Symbol into Complex (TypeError) 3.times { Complex(:sym, exception: false) } ^^^^^^^^^^^^^^^^^^^^^^ from local2.rb:1:in `block in
' from local2.rb:1:in `times' from local2.rb:1:in `
' local2.rb:1:in `Complex': can't convert Symbol into Complex (TypeError) 3.times { Complex(:sym, exception: false) } ^^^^^^^^^^^^^^^^^^^^^^ from local2.rb:1:in `block in
' from local2.rb:1:in `times' from local2.rb:1:in `
' local2.rb:1:in `Complex': can't convert Symbol into Complex (TypeError) 3.times { Complex(:sym, exception: false) } ^^^^^^^^^^^^^^^^^^^^^^ from local2.rb:1:in `block in
' from local2.rb:1:in `times' from local2.rb:1:in `
' ``` So the exception is still reported (instead of being swallow), but the puts, which is after, had the time to execute first. I can even put a `sleep()` in between and the exceptions are still reported after the puts. In a IRB, there is no exception at all and everything seems to work as expected. Happens if I pass in an Array too. Doesn't seem to happen with bad strings. There is also a quadratic behavior somewhere in there. Running the code in an IRB (which doesn't show exceptions), if you double the number of `times` in the loop, it takes 4x as long. This is probably related... -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/