Skip to content

Commit 28cac9a

Browse files
committed
Refactor rb_obj_call_init to pass block argument to initialize.
1 parent 42b4eea commit 28cac9a

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Bug fixes:
1717
* Fix `String#unpack("Z")` to not advance after the null byte, like CRuby (#2659, @aardvark179).
1818
* Fix `Float#round` to avoid losing precision during the rounding process (@aardvark179).
1919
* Fix `String#insert` to not call a subclassed string method (@bjfish).
20+
* Fix `rb_obj_call_init` to pass any block argument to the `initialize` method (#2675, @aardvark179).
2021

2122
Compatibility:
2223

lib/cext/ABI_check.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3
1+
4

lib/truffle/truffle/cext.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,8 +1217,8 @@ def rb_equal(a, b)
12171217
Primitive.object_same_or_equal(a, b)
12181218
end
12191219

1220-
def rb_obj_call_init(obj, args)
1221-
obj.__send__ :initialize, *args
1220+
def rb_obj_call_init(obj, args, block)
1221+
obj.__send__ :initialize, *args, &block
12221222
end
12231223

12241224
def rb_obj_instance_eval(obj, args, block)

src/main/c/cext/object.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ VALUE rb_equal(VALUE a, VALUE b) {
125125
}
126126

127127
void rb_obj_call_init(VALUE object, int argc, const VALUE *argv) {
128-
RUBY_CEXT_INVOKE_NO_WRAP("rb_obj_call_init", object, rb_ary_new4(argc, argv));
128+
RUBY_CEXT_INVOKE_NO_WRAP("rb_obj_call_init", object, rb_ary_new4(argc, argv), rb_block_proc());
129129
}
130130

131131
// taint status

0 commit comments

Comments
 (0)