Skip to content

v3: align enum fixed-array typedef names in callbacks - #28867

Closed
antono3 wants to merge 1 commit into
vlang:masterfrom
antono2:fix/v3-enum-fixed-array-fn-pointer
Closed

antono3 wants to merge 1 commit into
vlang:masterfrom
antono2:fix/v3-enum-fixed-array-fn-pointer

Conversation

@antono3

@antono3 antono3 commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Superseded by #28902

The refreshed #28902 at b06d4abc97644a67a2e6fcf6de20936d273335db includes this PR's sizeof(Callback) regression and passes it on current master 6c359c2282. It fixes callback key conversion while retaining backed-enum typedef names, so this separate global naming change is no longer needed.

Original proposal

Summary

V3 names fixed-array types in function pointer signatures through TypeChecker.c_type(), which renders enum elements as int. The C generator used value_c_type() for the emitted fixed-array typedef name, rendering the same enum as i32. The resulting C references Array_fixed_int_2 while only Array_fixed_i32_2 is declared.

Use TypeChecker.c_type() for enum elements when naming the generated typedef. Its element storage type remains unchanged. Add a regression case that compiles and runs a callback type with [2]Combiner through V3.

Reproducer before this change

module main
enum Combiner as i32 { keep = 0 replace = 1 }
type Callback = fn (command voidptr, ops [2]Combiner)
fn main() { _ = sizeof(Callback) }

v -new-compiler -cc gcc main.v fails with unknown type name 'Array_fixed_int_2'.

Validation

  • ./v self
  • ./v fmt -w on both touched files
  • ./v -silent test vlib/v/compiler_tests/fixed_array_typedef_codegen_test.v (pass)
  • VJOBS=4 ./v -silent test vlib/v/gen/c/ (25/25 pass)
  • The standalone reproducer compiles with ./v -new-compiler -cc gcc after the fix.

I also attempted ./v -silent vlib/v/compiler_errors_test.v; the current V3
runner disagreed with existing V1-format golden output for unrelated assertion
fixtures, so I stopped that broad run after the mismatch.

This was found while testing the Vulkan raw bindings' V3 C compatibility; the binding's platform declarations are separately guarded.

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.

1 participant