1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

parse.y: labeled heredoc

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

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2015-12-20 02:43:34 +00:00
parent a8b0c25293
commit 9d5abbff97
3 changed files with 12 additions and 1 deletions

View file

@ -1,3 +1,8 @@
Sun Dec 20 11:43:31 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* 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@atdot.net>
* proc.c (rb_mod_define_method): should check Symbol or not.

View file

@ -8330,7 +8330,7 @@ parser_yylex(struct parser_params *parser)
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;
}

View file

@ -342,6 +342,12 @@ WARN
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 }