summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2021-04-04 22:41:01 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2021-04-04 22:41:01 +0000
commitfebd8c91f63d53b38c3998567a45e3fc28c6bc58 (patch)
tree57be073c9801e87565472a3b73d11125e13586ab
parent49b37893a4189c388e51f711bd4164e1037e277b (diff)
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
-rw-r--r--variable.c17
-rw-r--r--version.h2
2 files changed, 15 insertions, 4 deletions
diff --git a/variable.c b/variable.c
index 89befc0c89..c3100f6e19 100644
--- a/variable.c
+++ b/variable.c
@@ -1984,9 +1984,11 @@ struct autoload_const {
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)
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)
}
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)
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 8c108d0c70..76a61174c6 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#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