[#68478] Looking for MRI projects for Ruby Google Summer of Code 2015 — Tony Arcieri <bascule@...>

Hi ruby-core,

10 messages 2015/03/10

[ruby-core:68451] [Ruby trunk - Bug #10947] [Rejected] Multiline if statement returns unexpected value instead of raising a syntax error

From: nobu@...
Date: 2015-03-07 02:12:51 UTC
List: ruby-core #68451
Issue #10947 has been updated by Nobuyoshi Nakada.

Description updated
Status changed from Open to Rejected

----------------------------------------
Bug #10947: Multiline if statement returns unexpected value instead of raising a syntax error
https://bugs.ruby-lang.org/issues/10947#change-51799

* Author: Sam Davies
* Status: Rejected
* Priority: Normal
* Assignee: 
* ruby -v: 2.1.2
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
Here is an invalid multiline if statement

~~~ruby
if (false &&
    false &&
    false
    true)
    puts "I was expecting an exception but saw this message instead"
end
~~~

As far as I can tell this is and should never be interpreted as valid syntax.

What actually happens is instead of raising an exception, ruby ignores all values except the last and only evaluates that. If you forget a `&&` at the end of a line this can result in very unexpected behavior.



-- 
https://bugs.ruby-lang.org/

In This Thread

Prev Next