Skip to content

Commit

Permalink
Merge pull request natalie-lang#1242 from herwinw/attr_warning
Browse files Browse the repository at this point in the history
Make attr spec-compliant (for real this time)
  • Loading branch information
seven1m authored Sep 24, 2023
2 parents 14f09a2 + 24a1da8 commit 4577a03
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 3 additions & 5 deletions spec/core/module/attr_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/module_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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--;
}
Expand Down

0 comments on commit 4577a03

Please sign in to comment.