Project

General

Profile

Actions

Bug #12073

closed

local variable interferes with keyword arguments

Added by josh.cheek (Josh Cheek) almost 9 years ago. Updated over 8 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin13]
[ruby-core:73816]

Description

This code causes a syntax error:

def a(b:)
  b
end
a = 1
a b: 9
 
# !> program.rb:5: syntax error, unexpected ':', expecting end-of-input
# !> a b: (9)
# !>     ^

However, if we remove the local assignment it works

def a(b:)
  b
end
a b: 9 # => 9

Or if we use parentheses it works

def a(b:)
  b
end
a = 1
a(b: 9) # => 9

Or if we use non-keyword arguments it works

def a(b)
  b
end
a = 1
a 9 # => 9
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0