Every ParseMoneyError variant repeats the text it read #39

Closed
opened 2026-08-16 00:35:40 +00:00 by rosa · 0 comments
Owner

What to build

All four ParseMoneyError variants carry the text the parser read. Because the
field sits inside each variant rather than beside them, text() and span()
are both four-arm matches whose only job is to reach a field every variant has.

Consider lifting the shared text out, leaving a struct that holds the text and a
kind that says what went wrong.

This needs a decision before it is built. miette's labels are declared per
variant, and the diagnostic output is a large part of what this error type is
for. Moving the text out may cost more in diagnostic wiring than the two matches
are worth. Settle that first — the answer may be to close this as wontfix.

It is a breaking change to a public type either way.

Acceptance criteria

  • A decision is recorded on whether the shape changes, and why
  • If it changes: text() and span() reach the text without matching on the kind
  • If it changes: miette still labels the byte ranges it labels today, including both ranges for conflicting currencies
  • If it changes: the breaking change is noted for the next release
  • mise run ci passes

Blocked by

#37. Both rework every place an error is built, and this decision is easier to
judge once a span is a type rather than a pointer subtraction.

## What to build All four `ParseMoneyError` variants carry the text the parser read. Because the field sits inside each variant rather than beside them, `text()` and `span()` are both four-arm matches whose only job is to reach a field every variant has. Consider lifting the shared text out, leaving a struct that holds the text and a kind that says what went wrong. **This needs a decision before it is built.** miette's labels are declared per variant, and the diagnostic output is a large part of what this error type is for. Moving the text out may cost more in diagnostic wiring than the two matches are worth. Settle that first — the answer may be to close this as wontfix. It is a breaking change to a public type either way. ## Acceptance criteria - [ ] A decision is recorded on whether the shape changes, and why - [ ] If it changes: `text()` and `span()` reach the text without matching on the kind - [ ] If it changes: miette still labels the byte ranges it labels today, including both ranges for conflicting currencies - [ ] If it changes: the breaking change is noted for the next release - [ ] `mise run ci` passes ## Blocked by #37. Both rework every place an error is built, and this decision is easier to judge once a span is a type rather than a pointer subtraction.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
rosa/lucre#39
No description provided.