Zig Version
0.14.0-dev.3267+59dc15fa0
Steps to Reproduce and Observed Behavior
I'm currently migrating my codebase from Zig 0.13.0 to 0.14.0-dev.3267+59dc15fa0, and I've noticed what might be unexpected behavior in the semantic analysis of functions.
In my test file, I'm using std.testing.refAllDecls which, as far as I understand, should trigger semantic analysis for all declarations. While this generally works as expected, I've observed that some functions seem to be skipped during analysis.
To reproduce:
- Check my repository's test file at tests/main.zig
- Notice the line
std.testing.refAllDecls(opencl.errors); which should analyze all declarations (src/errors.zig)
- Specifically, there's a public function
translate_opencl_error_for_all_fields that contains:
const opencl_error_fields = @typeInfo(opencl_error_enum).Enum.fields;
This should trigger an error as the correct syntax should be:
const opencl_error_fields = @typeInfo(opencl_error_enum).@"enum".fields;
- The semantic analysis also fails to detect this issue when trying to reference it with
_ = &opencl.errors.translate_opencl_error_for_all_fields
- The only way to trigger the analysis is by directly calling the function:
opencl.errors.translate_opencl_error_for_all_fields(0);
Question: Shouldn't refAllDecls trigger semantic analysis for all declarations? Is this intended behavior or potentially a bug?
I'm not entirely sure if this is a bug or if I'm misunderstanding how refAllDecls is supposed to work. Any clarification would be appreciated.
Expected Behavior
The compiler should detect and report that .Enum is an invalid field access or something like that
Zig Version
0.14.0-dev.3267+59dc15fa0
Steps to Reproduce and Observed Behavior
I'm currently migrating my codebase from Zig 0.13.0 to 0.14.0-dev.3267+59dc15fa0, and I've noticed what might be unexpected behavior in the semantic analysis of functions.
In my test file, I'm using
std.testing.refAllDeclswhich, as far as I understand, should trigger semantic analysis for all declarations. While this generally works as expected, I've observed that some functions seem to be skipped during analysis.To reproduce:
std.testing.refAllDecls(opencl.errors);which should analyze all declarations (src/errors.zig)translate_opencl_error_for_all_fieldsthat contains:This should trigger an error as the correct syntax should be:
_ = &opencl.errors.translate_opencl_error_for_all_fieldsopencl.errors.translate_opencl_error_for_all_fields(0);Question: Shouldn't
refAllDeclstrigger semantic analysis for all declarations? Is this intended behavior or potentially a bug?I'm not entirely sure if this is a bug or if I'm misunderstanding how
refAllDeclsis supposed to work. Any clarification would be appreciated.Expected Behavior
The compiler should detect and report that
.Enumis an invalid field access or something like that