diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-06-01 01:46:23 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-06-01 02:41:14 +0900 |
commit | c1e52997870a63168835fde49562cb3c822c968a (patch) | |
tree | 36a72b04c42dd45a25954279ca5d94f1377977ae /variable.c | |
parent | aeb9a0ca77725896ef072fa9bc0a031430a3a0e5 (diff) |
Fix FrozenError when assigning frozen class to constant
* variable.c (set_namespace_path): modules/classes can get named
by assignment to constant, even if frozen. [Bug #15891]
Diffstat (limited to 'variable.c')
-rw-r--r-- | variable.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/variable.c b/variable.c index ea618cee3d..ebfdf0dcce 100644 --- a/variable.c +++ b/variable.c @@ -2733,8 +2733,10 @@ static void set_namespace_path(VALUE named_namespace, VALUE namespace_path) { struct rb_id_table *const_table = RCLASS_CONST_TBL(named_namespace); - - rb_ivar_set(named_namespace, classpath, namespace_path); + if (!RCLASS_IV_TBL(named_namespace)) { + RCLASS_IV_TBL(named_namespace) = st_init_numtable(); + } + rb_class_ivar_set(named_namespace, classpath, namespace_path); if (const_table) { rb_id_table_foreach(const_table, set_namespace_path_i, &namespace_path); } |