[前][次][番号順一覧][スレッド一覧]

ruby-changes:41141

From: nobu <ko1@a...>
Date: Sun, 20 Dec 2015 11:43:46 +0900 (JST)
Subject: [ruby-changes:41141] nobu:r53214 (trunk): parse.y: labeled heredoc

nobu	2015-12-20 11:43:34 +0900 (Sun, 20 Dec 2015)

  New Revision: 53214

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53214

  Log:
    parse.y: labeled heredoc
    
    * parse.y (parser_yylex): allow here documents in labeled
      argument.  [ruby-core:72396] [Bug #11849]

  Modified files:
    trunk/ChangeLog
    trunk/parse.y
    trunk/test/ruby/test_syntax.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 53213)
+++ ChangeLog	(revision 53214)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Dec 20 11:43:31 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* parse.y (parser_yylex): allow here documents in labeled
+	  argument.  [ruby-core:72396] [Bug #11849]
+
 Sun Dec 20 11:14:11 2015  Koichi Sasada  <ko1@a...>
 
 	* proc.c (rb_mod_define_method): should check Symbol or not.
Index: parse.y
===================================================================
--- parse.y	(revision 53213)
+++ parse.y	(revision 53214)
@@ -8330,7 +8330,7 @@ parser_yylex(struct parser_params *parse https://github.com/ruby/ruby/blob/trunk/parse.y#L8330
 	if (c == '<' &&
 	    !IS_lex_state(EXPR_DOT | EXPR_CLASS) &&
 	    !IS_END() &&
-	    (!IS_ARG() || space_seen)) {
+	    (!IS_ARG() || IS_lex_state(EXPR_LABELED) || space_seen)) {
 	    int token = heredoc_identifier();
 	    if (token) return token;
 	}
Index: test/ruby/test_syntax.rb
===================================================================
--- test/ruby/test_syntax.rb	(revision 53213)
+++ test/ruby/test_syntax.rb	(revision 53214)
@@ -342,6 +342,12 @@ WARN https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L342
     assert_valid_syntax('{label: %w(*)}', bug11812)
   end
 
+  def test_heredoc_after_label
+    bug11849 = '[ruby-core:72396] [Bug #11849]'
+    assert_valid_syntax("{label:<<DOC\n""DOC\n""}", bug11849)
+    assert_valid_syntax("{label: <<DOC\n""DOC\n""}", bug11849)
+  end
+
   def test_duplicated_arg
     assert_syntax_error("def foo(a, a) end", /duplicated argument name/)
     assert_nothing_raised { def foo(_, _) end }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]