diff options
author | Jeremy Evans <code@jeremyevans.net> | 2020-03-27 15:08:52 -0700 |
---|---|---|
committer | Jeremy Evans <code@jeremyevans.net> | 2020-04-10 00:29:05 -0700 |
commit | 900e83b50115afda3f79712310e4cb95e4508972 (patch) | |
tree | 07c581a76af2b2e135f034eb52a9e81401e6e131 /insns.def | |
parent | defc0ee9d172c2caa8742cc682a8aa389942d6ef (diff) |
Turn class variable warnings into exceptions
This changes the following warnings:
* warning: class variable access from toplevel
* warning: class variable @foo of D is overtaken by C
into RuntimeErrors. Handle defined?(@@foo) at toplevel
by returning nil instead of raising an exception (the previous
behavior warned before returning nil when defined? was used).
Refactor the specs to avoid the warnings even in older versions.
The specs were checking for the warnings, but the purpose of
the related specs as evidenced from their description is to
test for behavior, not for warnings.
Fixes [Bug #14541]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/2987
Diffstat (limited to 'insns.def')
-rw-r--r-- | insns.def | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -236,7 +236,7 @@ getclassvariable /* "class variable access from toplevel" warning can be hooked. */ // attr bool leaf = false; /* has rb_warning() */ { - val = rb_cvar_get(vm_get_cvar_base(vm_get_cref(GET_EP()), GET_CFP()), id); + val = rb_cvar_get(vm_get_cvar_base(vm_get_cref(GET_EP()), GET_CFP(), 1), id); } /* Set value of class variable id of klass as val. */ @@ -249,7 +249,7 @@ setclassvariable // attr bool leaf = false; /* has rb_warning() */ { vm_ensure_not_refinement_module(GET_SELF()); - rb_cvar_set(vm_get_cvar_base(vm_get_cref(GET_EP()), GET_CFP()), id, val); + rb_cvar_set(vm_get_cvar_base(vm_get_cref(GET_EP()), GET_CFP(), 1), id, val); } /* Get constant variable id. If klass is Qnil and allow_nil is Qtrue, constants |