From 24a1da869cc79245854805772e3fd73a257d531c Mon Sep 17 00:00:00 2001 From: Herwin Date: Sat, 23 Sep 2023 18:04:20 +0200 Subject: [PATCH] Make attr spec-compliant (for real this time) Show a warning in verbose mode. --- spec/core/module/attr_spec.rb | 8 +++----- src/module_object.cpp | 2 ++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/core/module/attr_spec.rb b/spec/core/module/attr_spec.rb index 2a94d45a5..72a6646b1 100644 --- a/spec/core/module/attr_spec.rb +++ b/spec/core/module/attr_spec.rb @@ -137,11 +137,9 @@ def initialize end it "with a boolean argument emits a warning when $VERBOSE is true" do - NATFIXME 'Warnings', exception: SpecFailedException do - -> { - Class.new { attr :foo, true } - }.should complain(/boolean argument is obsoleted/, verbose: true) - end + -> { + Class.new { attr :foo, true } + }.should complain(/boolean argument is obsoleted/, verbose: true) end it "is a public method" do diff --git a/src/module_object.cpp b/src/module_object.cpp index 219beb385..6e91ea891 100644 --- a/src/module_object.cpp +++ b/src/module_object.cpp @@ -547,6 +547,8 @@ ArrayObject *ModuleObject::attr(Env *env, Args args) { bool accessor = false; auto size = args.size(); if (args.size() > 1 && args[size - 1]->is_boolean()) { + if (env->global_get("$VERBOSE"_s)->is_truthy()) + env->warn("optional boolean argument is obsoleted"); accessor = args[size - 1]->is_truthy(); size--; }