ruby-changes:48830
From: usa <ko1@a...>
Date: Thu, 30 Nov 2017 23:38:20 +0900 (JST)
Subject: [ruby-changes:48830] usa:r60947 (ruby_2_3): merge revision(s) 58499, 58500: [Backport #13181]
usa 2017-11-30 23:38:15 +0900 (Thu, 30 Nov 2017) New Revision: 60947 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60947 Log: merge revision(s) 58499,58500: [Backport #13181] parse.y: fix line in rescue * parse.y (set_line_body, primary): fix line number of bodystmt as the beginning of the block. [ruby-core:79388] [Bug #13181] parse.y: set_line_body is not used in ripper Modified directories: branches/ruby_2_3/ Modified files: branches/ruby_2_3/ChangeLog branches/ruby_2_3/parse.y branches/ruby_2_3/test/ruby/test_parse.rb branches/ruby_2_3/version.h Index: ruby_2_3/test/ruby/test_parse.rb =================================================================== --- ruby_2_3/test/ruby/test_parse.rb (revision 60946) +++ ruby_2_3/test/ruby/test_parse.rb (revision 60947) @@ -886,6 +886,19 @@ x = __ENCODING__ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/ruby/test_parse.rb#L886 assert_equal(-100, e.backtrace_locations.first.lineno, bug) end + def test_method_location_in_rescue + bug = '[ruby-core:79388] [Bug #13181]' + obj, line = Object.new, __LINE__+1 + def obj.location + # + raise + rescue + caller_locations(1, 1)[0] + end + + assert_equal(line, obj.location.lineno, bug) + end + =begin def test_past_scope_variable assert_warning(/past scope/) {catch {|tag| eval("BEGIN{throw tag}; tap {a = 1}; a")}} Index: ruby_2_3/parse.y =================================================================== --- ruby_2_3/parse.y (revision 60946) +++ ruby_2_3/parse.y (revision 60947) @@ -389,6 +389,17 @@ static int parser_yyerror(struct parser_ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/parse.y#L389 static int yylex(YYSTYPE*, struct parser_params*); +static inline void +set_line_body(NODE *body, int line) +{ + if (!body) return; + switch (nd_type(body)) { + case NODE_RESCUE: + case NODE_ENSURE: + nd_set_line(body, line); + } +} + #ifndef RIPPER #define yyparse ruby_yyparse @@ -2688,9 +2699,7 @@ primary : literal https://github.com/ruby/ruby/blob/trunk/ruby_2_3/parse.y#L2699 $$ = NEW_NIL(); } else { - if (nd_type($3) == NODE_RESCUE || - nd_type($3) == NODE_ENSURE) - nd_set_line($3, $<num>2); + set_line_body($3, $<num>2); $$ = NEW_BEGIN($3); } nd_set_line($$, $<num>2); @@ -2975,6 +2984,7 @@ primary : literal https://github.com/ruby/ruby/blob/trunk/ruby_2_3/parse.y#L2984 { /*%%%*/ $$ = NEW_CLASS($2, $5, $3); + set_line_body($5, $<num>4); nd_set_line($$, $<num>4); /*% $$ = dispatch3(class, $2, $3, $5); @@ -2994,6 +3004,7 @@ primary : literal https://github.com/ruby/ruby/blob/trunk/ruby_2_3/parse.y#L3004 { /*%%%*/ $$ = NEW_SCLASS($3, $6); + set_line_body($6, nd_line($3)); fixpos($$, $3); /*% $$ = dispatch2(sclass, $3, $6); @@ -3017,6 +3028,7 @@ primary : literal https://github.com/ruby/ruby/blob/trunk/ruby_2_3/parse.y#L3028 { /*%%%*/ $$ = NEW_MODULE($2, $4); + set_line_body($4, $<num>3); nd_set_line($$, $<num>3); /*% $$ = dispatch2(module, $2, $4); @@ -3041,6 +3053,7 @@ primary : literal https://github.com/ruby/ruby/blob/trunk/ruby_2_3/parse.y#L3053 NODE *body = remove_begin($6); reduce_nodes(&body); $$ = NEW_DEFN($2, $5, body, METHOD_VISI_PRIVATE); + set_line_body(body, $<num>1); nd_set_line($$, $<num>1); /*% $$ = dispatch3(def, $2, $5, $6); @@ -3066,6 +3079,7 @@ primary : literal https://github.com/ruby/ruby/blob/trunk/ruby_2_3/parse.y#L3079 NODE *body = remove_begin($8); reduce_nodes(&body); $$ = NEW_DEFS($2, $5, $7, body); + set_line_body(body, $<num>1); nd_set_line($$, $<num>1); /*% $$ = dispatch5(defs, $2, $3, $5, $7, $8); Index: ruby_2_3/version.h =================================================================== --- ruby_2_3/version.h (revision 60946) +++ ruby_2_3/version.h (revision 60947) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1 #define RUBY_VERSION "2.3.6" #define RUBY_RELEASE_DATE "2017-11-30" -#define RUBY_PATCHLEVEL 379 +#define RUBY_PATCHLEVEL 380 #define RUBY_RELEASE_YEAR 2017 #define RUBY_RELEASE_MONTH 11 Index: ruby_2_3/ChangeLog =================================================================== --- ruby_2_3/ChangeLog (revision 60946) +++ ruby_2_3/ChangeLog (revision 60947) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ChangeLog#L1 +Thu Nov 30 23:37:08 2017 Nobuyoshi Nakada <nobu@r...> + + parse.y: fix line in rescue + + * parse.y (set_line_body, primary): fix line number of bodystmt as the + beginning of the block. [Bug #13181] + Thu Nov 30 23:29:00 2017 SHIBATA Hiroshi <hsbt@r...> Merge rubygems-2.6.14 changes. Index: ruby_2_3 =================================================================== --- ruby_2_3 (revision 60946) +++ ruby_2_3 (revision 60947) Property changes on: ruby_2_3 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r58499-58500 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/