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

ruby-changes:65759

From: usa <ko1@a...>
Date: Mon, 5 Apr 2021 07:41:12 +0900 (JST)
Subject: [ruby-changes:65759] febd8c91f6 (ruby_2_6): merge revision(s) 2f1895fa15386fb3cdc91c5604171290828b9da8: [Backport #16767]

https://git.ruby-lang.org/ruby.git/commit/?id=febd8c91f6

From febd8c91f63d53b38c3998567a45e3fc28c6bc58 Mon Sep 17 00:00:00 2001
From: usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
Date: Sun, 4 Apr 2021 22:41:01 +0000
Subject: merge revision(s) 2f1895fa15386fb3cdc91c5604171290828b9da8: [Backport
 #16767]

	Fix source location of autoloaded constant [Bug #16764]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67915 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
---
 variable.c | 17 ++++++++++++++---
 version.h  |  2 +-
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/variable.c b/variable.c
index 89befc0..c3100f6 100644
--- a/variable.c
+++ b/variable.c
@@ -1984,9 +1984,11 @@ struct autoload_const { https://github.com/ruby/ruby/blob/trunk/variable.c#L1984
     VALUE mod;
     VALUE ad; /* autoload_data_i */
     VALUE value;
+    VALUE file;
     ID id;
     int safe_level;
     rb_const_flag_t flag;
+    int line;
 };
 
 /* always on stack, no need to mark */
@@ -2048,6 +2050,7 @@ autoload_c_mark(void *ptr) https://github.com/ruby/ruby/blob/trunk/variable.c#L2050
     rb_gc_mark(ac->mod);
     rb_gc_mark(ac->ad);
     rb_gc_mark(ac->value);
+    rb_gc_mark(ac->file);
 }
 
 static void
@@ -2838,6 +2841,7 @@ rb_const_set(VALUE klass, ID id, VALUE val) https://github.com/ruby/ruby/blob/trunk/variable.c#L2841
     }
     else {
 	struct autoload_const ac;
+	memset(&ac, 0, sizeof(ac));
 	ac.mod = klass;
 	ac.id = id;
 	ac.value = val;
@@ -2908,10 +2912,17 @@ const_tbl_update(struct autoload_const *ac) https://github.com/ruby/ruby/blob/trunk/variable.c#L2912
 		rb_clear_constant_cache();
 
 		ac->value = val; /* autoload_i is non-WB-protected */
-		return;
+                ac->file = rb_source_location(&ac->line);
 	    }
-	    /* otherwise, allow to override */
-	    autoload_delete(klass, id);
+            else {
+                /* otherwise autoloaded constant, allow to override */
+                autoload_delete(klass, id);
+                ce->flag = visibility;
+                RB_OBJ_WRITE(klass, &ce->value, val);
+                RB_OBJ_WRITE(klass, &ce->file, ac->file);
+                ce->line = ac->line;
+            }
+            return;
 	}
 	else {
 	    VALUE name = QUOTE_ID(id);
diff --git a/version.h b/version.h
index 8c108d0..76a6117 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L1
 #define RUBY_VERSION "2.6.7"
 #define RUBY_RELEASE_DATE "2021-04-05"
-#define RUBY_PATCHLEVEL 174
+#define RUBY_PATCHLEVEL 175
 
 #define RUBY_RELEASE_YEAR 2021
 #define RUBY_RELEASE_MONTH 4
-- 
cgit v1.1


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

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