Repository navigation
fix(fpc): complete opt-in function references - #632
Draft
edsontmarques wants to merge 1 commit into
Draft
edsontmarques wants to merge 1 commit into
edsontmarques wants to merge 1 commit into
Conversation
Keep managed callback declarations and router invocations consistent when HORSE_FPC_FUNCTIONREFERENCES is enabled, preserving procedural callbacks by default and upstream exception propagation. Add closure lifetime and routing regressions with bilingual guidance. Validated on FPC 3.3.1 and legacy 3.2.2; Delphi and the full upstream test matrix remain unverified. Co-Authored-By: Codex GPT-6 <noreply@openai.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem and change
With
HORSE_FPC_FUNCTIONREFERENCESenabled, a callback capturing a local variable does not compile against basea0ac019be1d29fd9deb20f61ca779d5631718bdb: the FPC callback declaration still selects the procedural record. This patch completes the existing opt-in path so managed callbacks can be registered and invoked consistently through Tree, Radix, middleware and lifecycle hooks.Horse has been useful in our projects. I would like to contribute this focused fix back and reduce the need to maintain a separate compatibility patch. I am opening it as a draft because I can provide the FPC results below, but cannot yet validate the full compiler and platform matrix.
The patch keeps procedural callbacks as the default. With the define enabled, it selects function-reference types, enables the required switches in the affected units, and uses typed managed callbacks for internal router continuations.
TNextProcshares the identity ofTProcin that mode. Older FPC versions receive an explicit diagnostic if the define is enabled. Applications must rebuild all units when switching modes.Exception handling keeps the upstream propagation contract: middleware wrapping
Nextcan still handle an exception before the existing outer fallback. The change adds no exception-catching fallback toNextCallerand no new global or thread-local state. Callback continuations remain synchronous; retainingNextbeyond the request is outside this proposal.Validation performed
All runs below target Linux x86_64. The trunk compiler identifies itself as
3.3.1-21317-g572d9b3138-unpushed(build 2026-10-15); these results apply to that revision.The new suite covers Tree and Radix, captured strings/interfaces after the callback factory returns, release of captured interfaces, middleware before/after
Next, request lifecycle hooks, abbreviated callbacks (including more than 64 registrations), separate instances, 404/405 finalizers and resumingNextafter nested dispatch. Test executions reported no unfreed heap blocks. The existing exception suite retains its 34 expectations.Reproduce from the repository root with Python 3, FPC and matching RTL/FCL units:
On FPC 3.2.2:
The runner supports
--compiler, repeated--compiler-argand--source-rootfor an isolated toolchain or a negative control. It rebuilds into separate temporary output directories for each test and mode. Instructions and compiler-support documentation are provided in English and Portuguese.Validation still needed
I have not run Delphi, FPC 3.2.0, other platforms, HTTP-provider integration, broad concurrent traffic, or the full
boss testsuite. The Delphi branches have been inspected, but inspection does not establish compiler compatibility. The direct router tests above do not establish transport integration or concurrency safety.I would appreciate help validating the shared units on Delphi and FPC 3.2.0, and running the full upstream test/CI matrix before considering this ready to merge. This draft does not claim that those compatibility requirements have been met.