mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
merge revision(s) 58638,58640: [Backport #11873]
test_syntax.rb: test_brace_after_local_variable * test/ruby/test_syntax.rb (test_brace_after_local_variable): another test using braces. [Bug #11873] parse.y: do after cmdarg in paren * parse.y (parser_yylex): set state to ENDARG after a string literal, so that `do` after a literal should be `do_block` and bound to the outer method, as well as a numeric/symbol literal. [ruby-core:72482] [Bug #11873] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@59406 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
66163b7749
commit
524e628fd3
3 changed files with 15 additions and 2 deletions
2
parse.y
2
parse.y
|
@ -8019,7 +8019,7 @@ parser_yylex(struct parser_params *parser)
|
|||
if (token == tSTRING_END || token == tREGEXP_END || token == tLABEL_END) {
|
||||
rb_gc_force_recycle((VALUE)lex_strterm);
|
||||
lex_strterm = 0;
|
||||
SET_LEX_STATE(token == tLABEL_END ? EXPR_BEG|EXPR_LABEL : EXPR_END);
|
||||
SET_LEX_STATE(token == tLABEL_END ? EXPR_BEG|EXPR_LABEL : EXPR_ENDARG);
|
||||
}
|
||||
}
|
||||
return token;
|
||||
|
|
|
@ -898,6 +898,10 @@ eom
|
|||
assert_valid_syntax %q{a b(c d), 1 do end}, bug11873
|
||||
assert_valid_syntax %q{a b{c(d)}, 1 do end}, bug11873
|
||||
assert_valid_syntax %q{a b(c(d)), 1 do end}, bug11873
|
||||
assert_valid_syntax %q{a b{c d}, "x" do end}, bug11873
|
||||
assert_valid_syntax %q{a b(c d), "x" do end}, bug11873
|
||||
assert_valid_syntax %q{a b{c(d)}, "x" do end}, bug11873
|
||||
assert_valid_syntax %q{a b(c(d)), "x" do end}, bug11873
|
||||
end
|
||||
|
||||
def test_block_after_cmdarg_in_paren
|
||||
|
@ -939,6 +943,15 @@ eom
|
|||
assert_equal(:ok, result)
|
||||
end
|
||||
|
||||
def test_brace_after_local_variable
|
||||
obj = Object.new
|
||||
def obj.m; yield; end
|
||||
result = assert_nothing_raised(SyntaxError) do
|
||||
obj.instance_eval("m = 1; m {:ok}")
|
||||
end
|
||||
assert_equal(:ok, result)
|
||||
end
|
||||
|
||||
def test_return_toplevel
|
||||
feature4840 = '[ruby-core:36785] [Feature #4840]'
|
||||
code = "#{<<~"begin;"}\n#{<<~"end;"}"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#define RUBY_VERSION "2.4.2"
|
||||
#define RUBY_RELEASE_DATE "2017-07-23"
|
||||
#define RUBY_PATCHLEVEL 157
|
||||
#define RUBY_PATCHLEVEL 158
|
||||
|
||||
#define RUBY_RELEASE_YEAR 2017
|
||||
#define RUBY_RELEASE_MONTH 7
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue