v3: use emitted fixed-array names in function pointers - #28902
Conversation
37eb4b0 to
b06d4ab
Compare
|
@codex review |
|
@codex review |
medvednikov
left a comment
There was a problem hiding this comment.
Reviewed b10ec41, including typedef collection, alias emission, return-wrapper registration, and the function-parameter emitter. The new alias-only and sizeof(Callback) cases are useful, but the emitted-name normalization is not yet used by every callback-signature path; see the inline comment.
Please extend the regression to pass and invoke a callback, in addition to declaring/measuring its type. That exercises the parameter declaration and the call ABI rather than only the alias's typedef.
This is a source review; I have not built V3 or executed these tests in this environment.
|
@codex review |
|
@codex review |
|
@codex review |
|
Callback parameters now use normalized type names, including nested signatures. The added regressions actually invoke V and C callbacks and cover aliases, fixed-array pointers, and Option/Result callback returns. |
|
Reviewed head [P2] Normalize callback signatures when emitting struct fields too
Consequently, putting the callback from the new regression into a struct still requests a different typedef key from the one preseeded here: the field-emission path encodes Please route those ordinary field fallbacks through the normalized function-type conversion too, preserving any explicit C-ABI override and pointer depth. Extend struct Holder {
cb Callback
}and, inside its generated holder := Holder{cb: first}
assert holder.cb([fixture.Mode.one, fixture.Mode.two]!) == 26The existing generated-C assertion rejecting This is a remaining normalization gap, not a claim that the unchanged field-emission code was introduced by this PR. I have not built V3 or executed the regressions locally: this environment has no V compiler and the repository clone failed because GitHub could not be resolved. |
Summary
V3 emits fixed-array typedefs using the backed enum's C name, while several function-pointer paths use a different TypeChecker encoding and refer to an undeclared
Array_fixed_int_2. Alias-only callback declarations can also omit their required fixed-array typedef.Use the emitted fixed-array name consistently in function-pointer keys and collect arrays reachable through type aliases. Resolve named callback aliases in
sizeofthrough the same key.This supersedes #28867: it covers that PR's imported
sizeof(Callback)case while retaining the backed-enum typedef name, instead of changing fixed-array naming globally. It is independent of #28868 (imported constants in array lengths).Verification against current master
Rebased onto
6c359c228241b44f9d9a942696e83b513931e532on 2026-09-26.-new-compiler), including native compilation, execution, and emitted typedef checks../v self, formatting verification, andgit diff --checkpass.fixed_array_typedef_codegen_test.vfile passes (all seven test functions).VJOBS=4 ./v -new-compiler test vlib/v/gen/c/passes: 28/28 test files.sizeofexpression retains the extra*.Latest tested head:
45ad1ea2fae51aa54e32545fa024aeba96dccdb1.The previously failing twelve formatter files now pass on master. The unrelated anonymous-struct compiler regression still fails on unmodified master in its genuinely anonymous parameter case.