[#61424] [REJECT?] xmalloc/xfree: reduce atomic ops w/ thread-locals — Eric Wong <normalperson@...>

I'm unsure about this. I _hate_ the extra branches this adds;

13 messages 2014/03/12

[ruby-core:61660] [ruby-trunk - Bug #9669] Inconsistent SyntaxError in Ruby 2.1 mandatory keyword arguments definition without parentheses.

From: matthew@...
Date: 2014-03-25 03:42:54 UTC
List: ruby-core #61660
Issue #9669 has been updated by Matthew Kerwin.


It's because of line continuations. It interpreted the code as:

~~~ruby
def foo a:, b: 'bar'
  # returns `nil`
end

def foo a:, b: puts 'bar'  #<< syntax error
end
~~~

There are two ways to add parentheses to make it legal:

~~~ruby
## CODE           |  ## INTERPRETED AS
                  |
def foo a:, b:    |  def foo a:, b: puts('bar')
  puts('bar')     |    # returns `nil`
end               |  end
                  |
def baz(a:, b:)   |  def foo(a:, b:)
  puts 'bar'      |    puts 'bar'
end               |  end
~~~

I think Ruby should drop the line continuation, and interpret all three code samples like the second case above, even though it might be hard to solve with the current parser.

----------------------------------------
Bug #9669: Inconsistent SyntaxError in Ruby 2.1 mandatory keyword arguments definition without parentheses.
https://bugs.ruby-lang.org/issues/9669#change-45918

* Author: Teja Sophista
* Status: Open
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: 2.1.1
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
Ruby allowed us to define method with arguments without parentheses.

~~~
def foo a:, b:
  'bar'
end
#=> :foo

def foo a:, b:
  puts 'bar'
end
#=> syntax error
~~~



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

In This Thread

Prev Next