Repository navigation
fix(validate): reject ptr<CallbackName> as unsupported pointer-to-callback shape - #7
Merged
Sam Gammon (sgammon) merged 2 commits intoOct 17, 2026
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7 +/- ##
============================================
+ Coverage 93.77% 93.82% +0.05%
- Complexity 656 658 +2
============================================
Files 18 18
Lines 1895 1895
Branches 391 392 +1
============================================
+ Hits 1777 1778 +1
Misses 37 37
+ Partials 81 80 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
…eThreadsAreValidated Add a test case naming a callback 'i64' (a scalar name) to exercise the require(!isScalarName(signature.name())) branch in Validator.validate, resolving the codecov/patch partial on the moved callbacks loop.
Sam Gammon (sgammon)
approved these changes
Oct 17, 2026
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.
Detail bug report: View on Detail
Bug
A function parameter declared
param cb type=ptr<Sink>, whereSinkis a declared callback signature, passed validation even though it describes a pointer to a function pointer — the same shape already rejected when spelledptr<fn<Sink>>. Callback names were registered into the sharedtypesset used to validate pointer pointees, so the "unknown pointee" check accepted them. But callbacks are lowered as function-pointer typedefs (typedef void (*Sink)(...)), not struct tags, so the C backend renderedstruct Sink *for astruct Sinkthat was never declared — producing a header that compiles with a warning, fails under-Werror, and is unusable at C call sites without casts.Struct fields using
ptr<Sink>were rejected only by accident of validation ordering (fields validated before callback names were registered), while function parameters validated afterward passed.Closes #5
Fix
Two changes in
Validator.java:type()method: Added arequire(!signatures.contains(n.name()), ...)check in thePointer(Named)branch so a pointer whoseNamedpointee is a callback signature is rejected with "pointers to callbacks are not supported; use fn<Name>", matching the existingptr<fn<Sink>>rejection.validate()method: Moved callback-name registration before struct-field validation so both struct fields and function parameters rejectptr<CallbackName>for the same stated reason, rather than struct fields rejecting it only by accident of ordering with a less helpful "unknown pointee" message.Testing
callbacksAndIsolateThreadsAreValidated:ptr<Sink>as a function parameter andptr<Sink>as a struct field — both must throwIllegalArgumentException.mvn -B verifypasses including the JaCoCo coverage gate (≥85% line, ≥70% branch).tests/e2e.py) passes: generated C header compiles undercc -std=c11 -Wall -Werror, Rust compiles, and FFM round-trip check passes.ptr<Sink>throws the expected message in both contexts, whilefn<Sink>,ptr<Handle>(opaque), andptr<ptr<u8>>(nested) continue to work correctly.Automatic Fixes PRs can be configured here.