ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:61658] [ruby-trunk - Bug #9669] [Open] Inconsistent SyntaxError in Ruby 2.1 mandatory keyword arguments definition without parentheses.
       [not found] <redmine.issue-9669.20140325023636@ruby-lang.org>
@ 2014-03-25  2:36 ` tejanium
  2014-03-25  3:33 ` [ruby-core:61659] [ruby-trunk - Bug #9669] " sawadatsuyoshi
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: tejanium @ 2014-03-25  2:36 UTC (permalink / raw
  To: ruby-core

Issue #9669 has been reported by Teja Sophista.

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

* 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/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ruby-core:61659] [ruby-trunk - Bug #9669] Inconsistent SyntaxError in Ruby 2.1 mandatory keyword arguments definition without parentheses.
       [not found] <redmine.issue-9669.20140325023636@ruby-lang.org>
  2014-03-25  2:36 ` [ruby-core:61658] [ruby-trunk - Bug #9669] [Open] Inconsistent SyntaxError in Ruby 2.1 mandatory keyword arguments definition without parentheses tejanium
@ 2014-03-25  3:33 ` sawadatsuyoshi
  2014-03-25  3:42 ` [ruby-core:61660] " matthew
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: sawadatsuyoshi @ 2014-03-25  3:33 UTC (permalink / raw
  To: ruby-core

Issue #9669 has been updated by Tsuyoshi Sawada.


That is consistent. In the first example, `'bar'` is interpreted as the default value of `b`. In the second example, the expression `puts 'bar'` is inappropriate as the default value, hence the error.

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

* 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/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ruby-core:61660] [ruby-trunk - Bug #9669] Inconsistent SyntaxError in Ruby 2.1 mandatory keyword arguments definition without parentheses.
       [not found] <redmine.issue-9669.20140325023636@ruby-lang.org>
  2014-03-25  2:36 ` [ruby-core:61658] [ruby-trunk - Bug #9669] [Open] Inconsistent SyntaxError in Ruby 2.1 mandatory keyword arguments definition without parentheses tejanium
  2014-03-25  3:33 ` [ruby-core:61659] [ruby-trunk - Bug #9669] " sawadatsuyoshi
@ 2014-03-25  3:42 ` matthew
  2014-03-25  4:52 ` [ruby-core:61667] " nobu
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: matthew @ 2014-03-25  3:42 UTC (permalink / raw
  To: ruby-core

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/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ruby-core:61667] [ruby-trunk - Bug #9669] Inconsistent SyntaxError in Ruby 2.1 mandatory keyword arguments definition without parentheses.
       [not found] <redmine.issue-9669.20140325023636@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2014-03-25  3:42 ` [ruby-core:61660] " matthew
@ 2014-03-25  4:52 ` nobu
  2014-03-25  5:25 ` [ruby-core:61670] " matthew
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: nobu @ 2014-03-25  4:52 UTC (permalink / raw
  To: ruby-core

Issue #9669 has been updated by Nobuyoshi Nakada.


Or put a semicolon after `b:`.

Matthew Kerwin wrote:
> 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.

Do you mean *all* line continuations?

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

* 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/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ruby-core:61670] [ruby-trunk - Bug #9669] Inconsistent SyntaxError in Ruby 2.1 mandatory keyword arguments definition without parentheses.
       [not found] <redmine.issue-9669.20140325023636@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2014-03-25  4:52 ` [ruby-core:61667] " nobu
@ 2014-03-25  5:25 ` matthew
  2014-03-25  7:47 ` [ruby-core:61672] [ruby-trunk - Bug #9669] [Closed] " nobu
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: matthew @ 2014-03-25  5:25 UTC (permalink / raw
  To: ruby-core

Issue #9669 has been updated by Matthew Kerwin.


Nobuyoshi Nakada wrote:
> Do you mean **all** line continuations?

I don't think so; the only one that ever comes up as a gotcha is a final required keyword argument in a function definition.

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

* 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/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ruby-core:61672] [ruby-trunk - Bug #9669] [Closed] Inconsistent SyntaxError in Ruby 2.1 mandatory keyword arguments definition without parentheses.
       [not found] <redmine.issue-9669.20140325023636@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2014-03-25  5:25 ` [ruby-core:61670] " matthew
@ 2014-03-25  7:47 ` nobu
  2014-03-25  7:50 ` [ruby-core:61673] [ruby-trunk - Bug #9669] " nobu
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: nobu @ 2014-03-25  7:47 UTC (permalink / raw
  To: ruby-core

Issue #9669 has been updated by Nobuyoshi Nakada.

Status changed from Open to Closed
% Done changed from 0 to 100

Applied in changeset r45405.

----------
parse.y: required kwarg without parentheses

* parse.y (lex_state_e, parser_params, f_arglist, parser_yylex):
  separate EXPR_LABELARG from EXPR_BEG and let newline significant,
  so that required keyword argument can place at the end of
  argument list without parentheses.  [ruby-core:61658] [Bug #9669]

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

* Author: Teja Sophista
* Status: Closed
* 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/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ruby-core:61673] [ruby-trunk - Bug #9669] Inconsistent SyntaxError in Ruby 2.1 mandatory keyword arguments definition without parentheses.
       [not found] <redmine.issue-9669.20140325023636@ruby-lang.org>
                   ` (5 preceding siblings ...)
  2014-03-25  7:47 ` [ruby-core:61672] [ruby-trunk - Bug #9669] [Closed] " nobu
@ 2014-03-25  7:50 ` nobu
  2014-03-25  8:15 ` [ruby-core:61674] [ruby-trunk - Bug #9669] [Open] " nobu
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: nobu @ 2014-03-25  7:50 UTC (permalink / raw
  To: ruby-core

Issue #9669 has been updated by Nobuyoshi Nakada.

Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN to 2.0.0: DONTNEED, 2.1: REQUIRED

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

* Author: Teja Sophista
* Status: Closed
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: 2.1.1
* Backport: 2.0.0: DONTNEED, 2.1: REQUIRED
----------------------------------------
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/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ruby-core:61674] [ruby-trunk - Bug #9669] [Open] Inconsistent SyntaxError in Ruby 2.1 mandatory keyword arguments definition without parentheses.
       [not found] <redmine.issue-9669.20140325023636@ruby-lang.org>
                   ` (6 preceding siblings ...)
  2014-03-25  7:50 ` [ruby-core:61673] [ruby-trunk - Bug #9669] " nobu
@ 2014-03-25  8:15 ` nobu
  2014-03-25 14:57 ` [ruby-core:61676] [ruby-trunk - Bug #9669] [Closed] " nobu
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: nobu @ 2014-03-25  8:15 UTC (permalink / raw
  To: ruby-core

Issue #9669 has been updated by Nobuyoshi Nakada.

Status changed from Closed to Open

It doesn't work yet...

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

* Author: Teja Sophista
* Status: Open
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: 2.1.1
* Backport: 2.0.0: DONTNEED, 2.1: REQUIRED
----------------------------------------
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/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ruby-core:61676] [ruby-trunk - Bug #9669] [Closed] Inconsistent SyntaxError in Ruby 2.1 mandatory keyword arguments definition without parentheses.
       [not found] <redmine.issue-9669.20140325023636@ruby-lang.org>
                   ` (7 preceding siblings ...)
  2014-03-25  8:15 ` [ruby-core:61674] [ruby-trunk - Bug #9669] [Open] " nobu
@ 2014-03-25 14:57 ` nobu
  2014-04-11  3:04 ` [ruby-core:61952] [ruby-trunk - Bug #9669] " nobu
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: nobu @ 2014-03-25 14:57 UTC (permalink / raw
  To: ruby-core

Issue #9669 has been updated by Nobuyoshi Nakada.

Status changed from Open to Closed

Applied in changeset r45408.

----------
parse.y: required kwarg without parentheses

* parse.y (parser_yylex): only a newline after label should be
  significant.  [ruby-core:61658] [Bug #9669]

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

* Author: Teja Sophista
* Status: Closed
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: 2.1.1
* Backport: 2.0.0: DONTNEED, 2.1: REQUIRED
----------------------------------------
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/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ruby-core:61952] [ruby-trunk - Bug #9669] Inconsistent SyntaxError in Ruby 2.1 mandatory keyword arguments definition without parentheses.
       [not found] <redmine.issue-9669.20140325023636@ruby-lang.org>
                   ` (8 preceding siblings ...)
  2014-03-25 14:57 ` [ruby-core:61676] [ruby-trunk - Bug #9669] [Closed] " nobu
@ 2014-04-11  3:04 ` nobu
  2014-05-18 15:37 ` [ruby-core:62662] " nagachika00
  2014-09-23  1:14 ` [ruby-core:65232] " nobu
  11 siblings, 0 replies; 12+ messages in thread
From: nobu @ 2014-04-11  3:04 UTC (permalink / raw
  To: ruby-core

Issue #9669 has been updated by Nobuyoshi Nakada.

Duplicated by Bug #9722: Failure with multiple keyword arguments added

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

* Author: Teja Sophista
* Status: Closed
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: 2.1.1
* Backport: 2.0.0: DONTNEED, 2.1: REQUIRED
----------------------------------------
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/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ruby-core:62662] [ruby-trunk - Bug #9669] Inconsistent SyntaxError in Ruby 2.1 mandatory keyword arguments definition without parentheses.
       [not found] <redmine.issue-9669.20140325023636@ruby-lang.org>
                   ` (9 preceding siblings ...)
  2014-04-11  3:04 ` [ruby-core:61952] [ruby-trunk - Bug #9669] " nobu
@ 2014-05-18 15:37 ` nagachika00
  2014-09-23  1:14 ` [ruby-core:65232] " nobu
  11 siblings, 0 replies; 12+ messages in thread
From: nagachika00 @ 2014-05-18 15:37 UTC (permalink / raw
  To: ruby-core

Issue #9669 has been updated by Tomoyuki Chikanaga.

Backport changed from 2.0.0: DONTNEED, 2.1: REQUIRED to 2.0.0: DONTNEED, 2.1: DONE

r45405 and r45408 were backported into `ruby_2_1` branch at r46005.

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

* Author: Teja Sophista
* Status: Closed
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: 2.1.1
* Backport: 2.0.0: DONTNEED, 2.1: DONE
----------------------------------------
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/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ruby-core:65232] [ruby-trunk - Bug #9669] Inconsistent SyntaxError in Ruby 2.1 mandatory keyword arguments definition without parentheses.
       [not found] <redmine.issue-9669.20140325023636@ruby-lang.org>
                   ` (10 preceding siblings ...)
  2014-05-18 15:37 ` [ruby-core:62662] " nagachika00
@ 2014-09-23  1:14 ` nobu
  11 siblings, 0 replies; 12+ messages in thread
From: nobu @ 2014-09-23  1:14 UTC (permalink / raw
  To: ruby-core

Issue #9669 has been updated by Nobuyoshi Nakada.

Related to Bug #10279: Syntax error on Hash with symbol syntax and nested expression: 2.1.3 regression  added

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

* Author: Teja Sophista
* Status: Closed
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: 2.1.1
* Backport: 2.0.0: DONTNEED, 2.1: DONE
----------------------------------------
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/

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-09-23  1:34 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <redmine.issue-9669.20140325023636@ruby-lang.org>
2014-03-25  2:36 ` [ruby-core:61658] [ruby-trunk - Bug #9669] [Open] Inconsistent SyntaxError in Ruby 2.1 mandatory keyword arguments definition without parentheses tejanium
2014-03-25  3:33 ` [ruby-core:61659] [ruby-trunk - Bug #9669] " sawadatsuyoshi
2014-03-25  3:42 ` [ruby-core:61660] " matthew
2014-03-25  4:52 ` [ruby-core:61667] " nobu
2014-03-25  5:25 ` [ruby-core:61670] " matthew
2014-03-25  7:47 ` [ruby-core:61672] [ruby-trunk - Bug #9669] [Closed] " nobu
2014-03-25  7:50 ` [ruby-core:61673] [ruby-trunk - Bug #9669] " nobu
2014-03-25  8:15 ` [ruby-core:61674] [ruby-trunk - Bug #9669] [Open] " nobu
2014-03-25 14:57 ` [ruby-core:61676] [ruby-trunk - Bug #9669] [Closed] " nobu
2014-04-11  3:04 ` [ruby-core:61952] [ruby-trunk - Bug #9669] " nobu
2014-05-18 15:37 ` [ruby-core:62662] " nagachika00
2014-09-23  1:14 ` [ruby-core:65232] " nobu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).