Repository navigation
Add scalar equality tags for complex64 and complex128 - #113
Merged
Merged
Conversation
Go can compare complex values with == and !=, and the zero value is 0+0i. Ordering tags stay rejected because complex numbers have no < or >.
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Complex pointers pass analyzer validation but fail later because matching generator conditions are intentionally absent.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Adds scalar complex-number validation support while rejecting unsupported ordering and composed forms.
Changes:
- Enables
eq,neq,in,nin, andrequiredforcomplex64/complex128. - Adds generator, analyzer, unit, and end-to-end coverage.
- Updates validation documentation and support matrices.
| File | Description |
|---|---|
README.md |
Documents complex validation support. |
docs/internals.md |
Explains complex generation behavior. |
internal/analyzer/analyzer_test.go |
Tests accepted and rejected complex operations. |
internal/analyzer/operations/operations_list.go |
Allows scalar complex operations. |
internal/analyzer/operations/operations_test.go |
Tests operation/type compatibility. |
internal/codegenerator/condition_table.go |
Adds complex equality and required conditions. |
internal/codegenerator/generated_function_code_no_pointer_test.go |
Adds generated-function expectations. |
internal/codegenerator/generated_validation_code_no_pointer_test.go |
Adds generated-validation expectations. |
internal/codegenerator/get_test_elements_all_types_test.go |
Tests complex condition elements. |
internal/codegenerator/get_test_elements_errors_test.go |
Tests unsupported complex forms. |
testgen/README.md |
Updates generator coverage documentation. |
testgen/coverage_test.go |
Skips unsupported complex pointer cases. |
testgen/generate_cmp_perf_tests.go |
Applies pointer exclusions to benchmarks. |
testgen/generate_function_code_tests.go |
Applies pointer exclusions to function tests. |
testgen/generate_validation_code_tests.go |
Applies pointer exclusions to validation tests. |
testgen/generate_validation_types_tests.go |
Applies pointer exclusions to end-to-end generation. |
testgen/validations.go |
Defines scalar complex test cases. |
tests/endtoend/complex.go |
Adds complex end-to-end scenarios. |
tests/endtoend/generated_endtoend_no_pointer_tests.go |
Adds generated scalar complex cases. |
tests/endtoend/main.go |
Runs the complex test suite. |
tests/endtoend/validator__.go |
Adds generated complex validators. |
Files not reviewed (4)
- internal/codegenerator/generated_function_code_no_pointer_test.go: Generated file
- internal/codegenerator/generated_validation_code_no_pointer_test.go: Generated file
- tests/endtoend/generated_endtoend_no_pointer_tests.go: Generated file
- tests/endtoend/validator__.go: Generated file
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
IsValidByType was treating a leading * as ignorable, so *complex64 passed the catalog and then failed in the generator. Those tags now fail analysis because there is no complex-pointer condition.
# Conflicts: # tests/endtoend/validator__.go
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Pointer-to-complex-container required validations still pass analysis and fail during code generation.
Review effort: Balanced
Findings: 1
Open (1)
Resolved since last review (1)
Files not reviewed (4)
- internal/codegenerator/generated_function_code_no_pointer_test.go: Generated file
- internal/codegenerator/generated_validation_code_no_pointer_test.go: Generated file
- tests/endtoend/generated_endtoend_no_pointer_tests.go: Generated file
- tests/endtoend/validator__.go: Generated file
|
|
||
| // Scalar complex pointers have no condition-table row. Reject them here | ||
| // so analysis does not accept a tag that generation cannot emit. | ||
| if pointer && normalized == "<COMPLEX>" { |
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.


Fixes #80
Summary
eq,neq,in,nin, andrequiredon scalarcomplex64andcomplex128. Equality uses Go==/!=.requireduses!= 0, the complex zero value0+0i.gt,gte,lt, andlteon complex types. Go has no<,>,<=, or>=for complex values, so those tags are analyzer errors and are not generated. Field ordering tags stay rejected from Add complex64 and complex128 field equality tags #108.skipPointer).Test plan
go test ./internal/analyzer/... ./internal/codegenerator/ ./testgen/make unittestsmake endtoendtestsfor both widths, including zero and nonzerorequired(0,0+1i,1+0i)