Actions
Bug #13691
closedWord- and symbol array literals not valid where regular array is
Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
Description
Not sure if this is a limitation of the design space in the parser, or just a missed edge case. (Note that a regular array literal works fine.)
Steps to reproduce:
Run ruby -c on:
hoge %i(a b) { piyo }
Expected behaviour:
Syntax OK
Actual behaviour:
syntax error, unexpected '{', expecting end-of-input
Updated by shevegen (Robert A. Heiler) over 7 years ago
Hmm you are right. That's interesting. I may be wrong but this may possibly be a limitation of the
parser, otherwise the ruby core team would have probably made it possible. (Though of course there
can be other reasons too... lack of resources... or nobody noticed this yet).
def foo(*i); pp i; end # => :foo
foo [:a, :b] { piyo } # => [[:a, :b]]
foo %i(a b) { piyo } # => SyntaxError: (irb):14: syntax error, unexpected '{', expecting end-of-input foo %i(a b) { piyo }
[:a, :b] == %i(a b) # => true
Interesting find though, anyway!
Updated by nobu (Nobuyoshi Nakada) over 7 years ago
- Is duplicate of Bug #505: 1.upto 2 {|i| p i } added
Updated by nobu (Nobuyoshi Nakada) over 7 years ago
- Related to Bug #13547: [].delete 1 { 'NG' } added
Updated by nobu (Nobuyoshi Nakada) over 7 years ago
Because of the precedence, {}
is bound to %i()
here, and %i()
literal cannot be a method call.
Updated by wanabe (_ wanabe) about 7 years ago
- Related to Bug #14023: SyntaxError on array argument and block added
Updated by jeremyevans0 (Jeremy Evans) over 5 years ago
- Status changed from Open to Rejected
Actions
Like0
Like0Like0Like0Like0Like0Like0