Summary
Semantics.SourceGenerators/Generators/QuantitiesGenerator.cs deduplicates emitted operators using simple string keys (e.g. "Dot:{selfType}:{otherType}:{resultType}", "Mul:{a}:{b}"). These keys are not symmetric across operand order, so the generator can emit:
- both
A * B and B * A for commutative multiplications
- a
Dot(B) on A and another Dot(A) on B whose generated bodies represent the same scalar product
The result is duplicate definitions or — worse — slightly inconsistent ones if metadata changes between sweeps.
Evidence
QuantitiesGenerator.cs:153-161 and :245-278 build the dedup keys directly from operand order.
- Self-divide is handled as a special case (
:161) but no equivalent commutative normalisation exists for cross-dimensional ops.
Suggested next step
- Normalise operand order in dedup keys (e.g. sort the operand type names alphabetically when the relationship is declared commutative).
- Add a generator-level invariant test that compiles a small fixture and asserts no duplicate methods/operators per generated type.
Area / Severity
SourceGenerators · incomplete
Summary
Semantics.SourceGenerators/Generators/QuantitiesGenerator.csdeduplicates emitted operators using simple string keys (e.g."Dot:{selfType}:{otherType}:{resultType}","Mul:{a}:{b}"). These keys are not symmetric across operand order, so the generator can emit:A * BandB * Afor commutative multiplicationsDot(B)onAand anotherDot(A)onBwhose generated bodies represent the same scalar productThe result is duplicate definitions or — worse — slightly inconsistent ones if metadata changes between sweeps.
Evidence
QuantitiesGenerator.cs:153-161and:245-278build the dedup keys directly from operand order.:161) but no equivalent commutative normalisation exists for cross-dimensional ops.Suggested next step
Area / Severity
SourceGenerators · incomplete