Skip to content

Commit d7bc082

Browse files
committed
Correctly return a FFI::function if the return type is FFI::FunctionType
1 parent aec8c03 commit d7bc082

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Bug fixes:
99
* Implemented `rb_eval_string_protect`.
1010
* Fixed `rb_get_kwargs` to correctly handle optional and rest arguments.
1111
* Calling `Kernel#raise` with a raised exception will no longer set the cause of the exception to itself (#1682).
12+
* Return a `FFI::Function` correctly for functions returning a callback.
1213

1314
Compatibility
1415

lib/truffle/truffle/ffi_backend/function.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ def free
170170
elsif FFI::Type::Builtin === type and type.unsigned?
171171
# TODO: NFI workaround
172172
type.signed2unsigned(value)
173+
elsif FFI::FunctionType === type
174+
ptr = FFI::Pointer.new(Truffle::Interop.as_pointer(value))
175+
FFI::Function.new(type, nil, ptr)
173176
else
174177
value
175178
end

0 commit comments

Comments
 (0)