summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gc.rb10
-rw-r--r--test/ruby/test_gc.rb4
2 files changed, 10 insertions, 4 deletions
diff --git a/gc.rb b/gc.rb
index 2a75e166ce..f3221c5761 100644
--- a/gc.rb
+++ b/gc.rb
@@ -306,7 +306,15 @@ module GC
def self.config hash = nil
return Primitive.gc_config_get unless hash
- Primitive.gc_config_set hash
+ if(Primitive.cexpr!("RBOOL(RB_TYPE_P(hash, T_HASH))"))
+ if hash.include?(:implementation)
+ raise ArgumentError, 'Attempting to set read-only key "Implementation"'
+ end
+
+ Primitive.gc_config_set hash
+ else
+ raise ArgumentError
+ end
end
# call-seq:
diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb
index 1eb5451b3f..72fab5c43c 100644
--- a/test/ruby/test_gc.rb
+++ b/test/ruby/test_gc.rb
@@ -127,9 +127,7 @@ class TestGc < Test::Unit::TestCase
def test_gc_config_implementation_is_readonly
omit unless /darwin|linux/.match(RUBY_PLATFORM)
- impl = GC.config[:implementation]
- GC.config(implementation: "somethingelse")
- assert_equal(impl, GC.config[:implementation])
+ assert_raise(ArgumentError) { GC.config(implementation: "somethingelse") }
end
def test_start_full_mark