Skip to content

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

Merged
mathleur merged 2 commits into
mainfrom
fix/coordinate-correctness
Jul 13, 2026
Merged

fix(coordinates): consistent leading-zero handling, safe intersection, type coercion#104
mathleur merged 2 commits 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

@mathleur mathleur left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good to me, might need to create special formatting functions for expver and similar data keys which require special treatment later

@mathleur mathleur marked this pull request as ready for review July 13, 2026 12:34
@mathleur mathleur merged commit 7d22040 into main Jul 13, 2026
2 checks passed
@mathleur mathleur deleted the fix/coordinate-correctness branch July 13, 2026 12:42
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.

2 participants