Skip to content

fix(coordinates): consistent leading-zero handling, safe intersection, type coercion#104

Draft
HCookie wants to merge 1 commit into
mainfrom
fix/coordinate-correctness
Draft

fix(coordinates): consistent leading-zero handling, safe intersection, type coercion#104
HCookie wants to merge 1 commit into
mainfrom
fix/coordinate-correctness

Conversation

@HCookie

@HCookie HCookie commented Jun 23, 2026

Copy link
Copy Markdown
Member

Summary

Fixes correctness issues in the coordinate system that caused panics and data corruption during merge operations.

Changes

Leading-zero consistency

  • When multiple values are present (e.g. 0600/1200), if any value has a leading zero, all are kept as strings. Previously each value was checked independently, causing inconsistent typing within a single coordinate set.

Mixed coordinates to_string()

  • Implemented the Mixed variant's to_string() method (was todo!()).

Safe intersection

  • intersect() now returns Empty instead of panicking on cross-type or empty operands.
  • Added wrap_ints/wrap_strs helpers to return Empty for zero-length intersection results.

Type coercion on extend

  • When extending Strings with Integers (or vice versa), attempts coercion before falling back to Mixed. This avoids spurious Mixed variants when merging e.g. "1" with 1.

Tests

  • Comprehensive unit tests for integer/string/cross-type/empty intersection cases.

Part of the split from #102.

…, type coercion

- Fix leading-zero detection to be consistent across multi-value strings
  (e.g. '0600/1200' stays as strings, not parsed as integers)
- Implement Mixed coordinates to_string() (was todo!())
- Fix intersect() to return Empty instead of panicking on cross-type or
  empty operands
- Add type coercion between Strings and Integers when extending
  coordinates (avoids spurious Mixed variants when merging '1' with 1)
- Add helper functions wrap_ints/wrap_strs to return Empty for zero-length
  results
- Add comprehensive unit tests for intersection edge cases
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