From: nagachika00@... Date: 2018-10-01T12:02:40+00:00 Subject: [ruby-core:89232] [Ruby trunk Bug#14897] Unexpected behavior of `if` in specific code Issue #14897 has been updated by nagachika (Tomoyuki Chikanaga). Backport changed from 2.3: DONTNEED, 2.4: DONTNEED, 2.5: REQUIRED to 2.3: DONTNEED, 2.4: DONTNEED, 2.5: DONE ruby_2_5 r64893 merged revision(s) 63868,63870. ---------------------------------------- Bug #14897: Unexpected behavior of `if` in specific code https://bugs.ruby-lang.org/issues/14897#change-74259 * Author: peitetsu (teppei takeo) * Status: Closed * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin17] * Backport: 2.3: DONTNEED, 2.4: DONTNEED, 2.5: DONE ---------------------------------------- I found a strange behavior of `if` in the following code. ~~~ ruby def seems_bug(obj) if obj || obj obj = obj else raise obj.inspect end obj end seems_bug('foo') #=> RuntimeError: "foo" ~~~ This code is expected to return "foo", but the error on the else clause occurs. The same error occurs in the following code. ~~~ ruby def seems_bug(obj) if obj || any1 any2 = any2 else raise obj.inspect end obj end seems_bug('foo') #=> RuntimeError: "foo" ~~~ -- https://bugs.ruby-lang.org/ Unsubscribe: