Bug #10653

do-end block in ternary operator is syntax error

Shinta Koyanagi12ヶ月前に追加. 2ヶ月前に更新.

[ruby-dev:48790]
ステータス:Closed
優先度:Normal
担当者:Yukihiro Matsumoto
ruby -v:ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin14] Backport:2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: DONE

説明

  • For example
ruby -v -e 'true ? 1.tap do |n| p n end : 0'
  • Result by 2.1.5
ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-darwin14.0]
1
  • Result by 2.2.0
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin14]
-e:1: syntax error, unexpected keyword_do_cond, expecting ':'
true ? 1.tap do |n| p n end : 0
               ^
-e:1: syntax error, unexpected tIDENTIFIER, expecting keyword_do or '{' or '('
true ? 1.tap do |n| p n end : 0
                       ^

関連するチケット

関連している Ruby trunk - Feature #4276: Allow use of quotes in symbol syntactic sugar for hashes Closed 2011/01/13
関連している Ruby trunk - Bug #11456: Hash リテラル中で rescue をもちいると SyntaxError になる Closed

関係しているリビジョン

リビジョン 51617
Nobuyoshi Nakada4ヶ月前に追加

parse.y: fix block after conditional

  • parse.y: fix syntax error at do-block after a conditional operator. separate label-allowed and after-a-label states from others as bit flags. [Bug #10653]

リビジョン 52046
Tomoyuki Chikanaga2ヶ月前に追加

merge revision(s) 50409,51616,51617,51624: [Backport #10653] [Backport #11456]

parse.y: %-string cannot be a label

* parse.y (parser_yylex): %-string cannot be a label even if

terminated by single/double quotes.
* parse.y: fix syntax error at do-block after a conditional
operator. separate label-allowed and after-a-label states from
others as bit flags. [Bug #10653]

* parse.y (IS_BEG): include labeled argument state, which was
  EXPR_LABELARG.   [Bug #11456]

履歴

#1 Nobuyoshi Nakada12ヶ月前に更新

  • 関連している Feature #4276: Allow use of quotes in symbol syntactic sugar for hashes を追加

#2 Nobuyoshi Nakada4ヶ月前に更新

  • Backport2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN から 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: REQUIRED に変更

#3 Nobuyoshi Nakada4ヶ月前に更新

  • ステータスOpen から Closed に変更

Applied in changeset r51617.


parse.y: fix block after conditional

  • parse.y: fix syntax error at do-block after a conditional operator. separate label-allowed and after-a-label states from others as bit flags. [Bug #10653]

#4 Nobuyoshi Nakada4ヶ月前に更新

  • 関連している Bug #11456: Hash リテラル中で rescue をもちいると SyntaxError になる を追加

#5 Tomoyuki Chikanaga2ヶ月前に更新

After backporting r50409 and r51617, TestSyntax#test_block_after_cond failed.

#6 Tomoyuki Chikanaga2ヶ月前に更新

r51616 should be backported too?

#7 Tomoyuki Chikanaga2ヶ月前に更新

  • Backport2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: REQUIRED から 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: DONE に変更

r50409, r51616, r51617 and r51624 were backported into ruby_2_2 branch at r52046.
With r50409 a minor incompatibility is introduced ({ %w"key": 0 } cause SyntaxError).
I'm not confident the incompatibility is essential part of this fixes, but the accurate surgery is required to eliminate the incompatibility. I gave up.

他の形式にエクスポート: Atom PDF