Skip to content

Conversation

brettmc
Copy link
Contributor

@brettmc brettmc commented Aug 29, 2025

Previously, storing "mysterious code" in common.arg_info was ok if nothing else was in arg_info. However, when a return type-hint is registered against a function (or anything else that populates arg_info), the slot in arg_info is clobbered by the return type info. Previous tests for adding type-hints appeared correct because they were only inspecting the Reflection of the function, which appeared correct. Only when the function was invoked did it fail to locate the mysterious code, and assume the function was a method and could be found in globals().handler_map (which would panic because function handlers were not globally registered).

To fix this, remove mysterious code entirely, and store function handlers globally, alongside methods and enums.

Previously, storing "mysterious code" in common.arg_info was ok if nothing else was in
arg_info. However, when a type-hint is registered against a function, the slot in arg_info
is clobbered by the return type info. Previous tests for adding type-hints appeared correct
because they were only inspecting the Reflection of the function, which appeared correct.
Only when the function was invoked did it fail to locate the mysterious code, and assume
the function was a method and could be found in globals().handler_map (which would panic
because function handlers were not globally registered).

To fix this, remove mysterious code entirely, and store function handlers globally, alongside
methods and enums.
@brettmc brettmc changed the title fix invocation of functions with return type hint fix invocation of functions with type hint Aug 29, 2025
@jmjoy jmjoy merged commit 2e01785 into phper-framework:master Aug 29, 2025
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants