ruby-changes:47372
From: nagachika <ko1@a...>
Date: Thu, 3 Aug 2017 22:29:20 +0900 (JST)
Subject: [ruby-changes:47372] nagachika:r59488 (ruby_2_4): merge revision(s) 58503: [Backport #13523]
nagachika 2017-08-03 22:29:12 +0900 (Thu, 03 Aug 2017) New Revision: 59488 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59488 Log: merge revision(s) 58503: [Backport #13523] node.h: sign-extend * node.h (nd_line): should sign-extend. shifting `VALUE` extends with zero bits if `sizeof(VALUE)` equals to `sizeof(int)`. the zero bits are truncated if `sizeof(VALUE)` is bigger enough. [ruby-core:80920] [Bug #13523] Modified directories: branches/ruby_2_4/ Modified files: branches/ruby_2_4/node.h branches/ruby_2_4/test/ruby/test_parse.rb branches/ruby_2_4/version.h Index: ruby_2_4/test/ruby/test_parse.rb =================================================================== --- ruby_2_4/test/ruby/test_parse.rb (revision 59487) +++ ruby_2_4/test/ruby/test_parse.rb (revision 59488) @@ -960,6 +960,16 @@ x = __ENCODING__ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/test/ruby/test_parse.rb#L960 assert_syntax_error(" 0b\n", /\^/) end + def test_negative_line_number + bug = '[ruby-core:80920] [Bug #13523]' + obj = Object.new + obj.instance_eval("def t(e = false);raise if e; __LINE__;end", "test", -100) + assert_equal(-100, obj.t, bug) + assert_equal(-100, obj.method(:t).source_location[1], bug) + e = assert_raise(RuntimeError) {obj.t(true)} + assert_equal(-100, e.backtrace_locations.first.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_4/node.h =================================================================== --- ruby_2_4/node.h (revision 59487) +++ ruby_2_4/node.h (revision 59488) @@ -277,7 +277,7 @@ typedef struct RNode { https://github.com/ruby/ruby/blob/trunk/ruby_2_4/node.h#L277 #define NODE_LSHIFT (NODE_TYPESHIFT+7) #define NODE_LMASK (((SIGNED_VALUE)1<<(sizeof(VALUE)*CHAR_BIT-NODE_LSHIFT))-1) -#define nd_line(n) (int)(RNODE(n)->flags>>NODE_LSHIFT) +#define nd_line(n) (int)(((SIGNED_VALUE)RNODE(n)->flags)>>NODE_LSHIFT) #define nd_set_line(n,l) \ RNODE(n)->flags=((RNODE(n)->flags&~((VALUE)(-1)<<NODE_LSHIFT))|((VALUE)((l)&NODE_LMASK)<<NODE_LSHIFT)) Index: ruby_2_4/version.h =================================================================== --- ruby_2_4/version.h (revision 59487) +++ ruby_2_4/version.h (revision 59488) @@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1 #define RUBY_VERSION "2.4.2" -#define RUBY_RELEASE_DATE "2017-07-23" -#define RUBY_PATCHLEVEL 161 +#define RUBY_RELEASE_DATE "2017-08-03" +#define RUBY_PATCHLEVEL 162 #define RUBY_RELEASE_YEAR 2017 -#define RUBY_RELEASE_MONTH 7 -#define RUBY_RELEASE_DAY 23 +#define RUBY_RELEASE_MONTH 8 +#define RUBY_RELEASE_DAY 3 #include "ruby/version.h" Index: ruby_2_4 =================================================================== --- ruby_2_4 (revision 59487) +++ ruby_2_4 (revision 59488) Property changes on: ruby_2_4 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r58503 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/