Bug #10279
closed
Syntax error on Hash with symbol syntax and nested expression: 2.1.3 regression
Added by jackmontaach (Jack Montaach) about 10 years ago.
Updated about 10 years ago.
Description
The following gives syntax error on ruby 2.1.3
h = { key: if true
"yes"
else
"no"
end }
puts h.inspect
/usr/local/rvm/rubies/ruby-2.1.3/bin/ruby x.rb
x.rb:1: syntax error, unexpected modifier_if
h = { key: if true
^
x.rb:3: syntax error, unexpected keyword_else, expecting end-of-input
/usr/local/rvm/rubies/ruby-2.1.2/bin/ruby x.rb
{:key=>"yes"}
trunk is same behaviour:
ruby 2.2.0preview1 (2014-09-17 trunk 47616) [x86_64-darwin13]
10279.rb:1: syntax error, unexpected modifier_if
h = { key: if true
- Description updated (diff)
- Category changed from core to syntax
- Status changed from Open to Assigned
- Assignee changed from matz (Yukihiro Matsumoto) to nobu (Nobuyoshi Nakada)
- Related to Bug #9669: Inconsistent SyntaxError in Ruby 2.1 mandatory keyword arguments definition without parentheses. added
- Backport set to 2.0.0: DONTNEED, 2.1: REQUIRED
- Status changed from Assigned to Closed
- % Done changed from 0 to 100
Applied in changeset r47696.
parse.y: label cannot be followed by a modifier
- parse.y (parse_ident): just after a label, new expression should
start, cannot be a modifier. [ruby-core:65211] [Bug #10279]
- Backport changed from 2.0.0: DONTNEED, 2.1: REQUIRED to 2.0.0: DONTNEED, 2.1: DONE
Backported r47696 and r47697 into ruby_2_1
branch at r47703.
- Has duplicate Bug #10288: Parser incompatibility between 2.1.2 and 2.1.3 added
Also available in: Atom
PDF
Like0
Like0Like0Like0Like0Like0Like0Like0