Typeset Error.No Greedy Plan()- Module
- std.
typeset - Receiver
- Not applicable
- Minimum arity
- 0
- Maximum arity
- 0
Declaration and parameters
LinkAvailability
Included by default: Pending
Import std.typeset in language mode 5.21.
The current compiler selects std/typeset.tpz for this language mode. Availability in other released editions and inclusion in each installed distribution are Pending.
Source evidence
- compiler/crates/topaz_resolve/src/std/typeset/model.tpz at
b48527d0a174· 8 - compiler/crates/topaz_resolve/src/stdlib.rs at
b48527d0a174· 40
Receiver
Parameter constraints
breakParagraph evaluates its Paragraph argument through the ordinary call rules, then reads its item sequence and policies. Planning performs no input mutation, text shaping, external I/O, or random selection. The same ordered input and computation rules produce the same lines and scores.
Paragraph.items supplies measured BoxItem and GlueItem units with contiguous indices from zero. PenaltyItem entries refer to boundaries between those units. The planner uses these measurements and supplied penalties directly. It does not call classifyBreaks or insert a terminal penalty.
Paragraph.grid selects integer quantization at the computation boundary. Every public distance remains Length<Pt>. FixedPoint requires MilliPoint. KnuthPlass accepts either DistanceGrid. The ordinary checked length conversion applies before integer planning.
Policy validation precedes item validation. Geometry, the cost model and grid combination, justification values, and KnuthPlassPolicy are validated even when a chosen model does not use a policy field for scoring. Invalid configuration returns TypesetError.InvalidPolicy. Invalid unit indices, capacities, or penalty endpoints return TypesetError.InvalidInput.
A valid empty items array returns two empty plans with zero totalCost and zero breakOpportunityCount. This case still validates the policies. Each empty plan reports its selected grid and None() for boundedFillFeasible.
For nonempty input, the planner orders penalties by increasing unitEnd and preserves supplied order at equal boundaries. Allowed and Forced entries are candidates. Forbidden entries are excluded individually. Duplicate candidates remain distinct. A Forced entry requires the plan to visit its boundary, where another eligible entry may be selected.
No candidates returns TypesetError.NoBreakOpportunities. The planner constructs the greedy baseline before the optimized search. Failure to complete that baseline returns TypesetError.NoGreedyPlan. A completed baseline followed by an unsuccessful optimized search returns TypesetError.NoPlan. An Err result contains no partial ParagraphResult.
For FixedPoint, greedy chooses the farthest raw width that fits the next target before the first overwide candidate or Forced boundary. If the first candidate is already overwide, greedy chooses it to advance. For KnuthPlass, greedy chooses the last ratio-admissible candidate up to the next Forced boundary. Every chosen boundary advances past the previous one.
FixedPoint optimization starts with the preceding 80 candidates at each destination. It extends the search backward while the preceding span fits the larger base target plus available shrink and one grid unit. It retains the least score for each boundary and semantic state. It admits at most two consecutive LatinSoftHyphen breaks.
FixedPoint optimized admission uses trimmed text width plus the selected penalty width. The width limit is the target plus available shrink for a nonfinal line, with one grid unit of rounding allowance. A line containing one unit can exceed this limit so an indivisible unit can make progress. Greedy reports the same limit but selects candidates using its raw width rule.
With FixedPoint, a justified mode, and Some(latinSpacing), optimization first searches for a complete plan whose lines satisfy the bounded fill check. It prefers that plan when found. Otherwise it repeats the search without that check. This preference can select a plan with a higher totalCost than the greedy plan.
KnuthPlass optimization considers every preceding candidate and retains each distinct line geometry bucket, fitness class, and flagged state at a boundary. FixedPoint also retains its soft hyphen streak. State buckets distinguish drop cap lines and collapse after the inset ends.
Equal scores retain the first visited predecessor. Candidates are visited in boundary order, with supplied order at equal boundaries. States are visited by increasing line geometry bucket, soft hyphen streak, fitness class, and then unflagged before flagged. Final selection uses the same first-on-equal rule.
The optimized field reports the selected model search and admission policy. The greedy field reports its baseline from the same input. Each reported cost belongs to the plan selected by these candidate, state, and admission rules. Ordinary checked arithmetic faults remain faults and are not converted into a TypesetError value.
Related rule: Choose deterministic paragraph plansTypesetError values are returned in Err by the typesetting operations that declare them. InvalidInput carries explanatory text for invalid measured data or boundary structure. InvalidPolicy carries explanatory text for an invalid algorithm configuration.
The string payload describes a cause. Programs distinguish failure categories by matching the variant rather than comparing library message text. Constructing an error value directly preserves its supplied string.
NoBreakOpportunities means a nonempty paragraph has no selectable penalty candidate after validation and filtering. It does not mean that the selected cost model searched unsuccessfully.
NoGreedyPlan means a validated paragraph has selectable candidates but its deterministic greedy baseline cannot reach the final unit. NoPlan means that baseline completed but the selected optimization search found no permitted complete plan.
A successful empty paragraph has two empty plans and zero candidates under the paragraph contract. It is not a missing-opportunity failure.
breakParagraph validates policy configuration before measured items. It then checks candidates, builds the greedy plan, and searches for an optimized plan in that order. The first failing stage determines the returned variant.
The policy stages check geometry, the cost model and grid combination, justification settings, and KnuthPlass settings. Item validation follows source encounter order and checks collected penalty endpoints after the measured units.
classifyBreaks applies its input and break-policy validation rules. The shared error variants do not impose paragraph validation order on break classification.
An Err contains no partial ParagraphResult and does not mutate the supplied input. Previously completed argument effects remain completed. A failure while evaluating an argument keeps its ordinary language diagnostic and prevents the typesetting call.
Related rule: Distinguish invalid data from unavailable plansResult
Effects
Failures
Result and effects
LinkThe operation found candidates but returns no partial ParagraphResult when its baseline fails.
Why
LinkA named failure category lets callers select a recovery without depending on message wording.
Resolved contracts
LinkRelated entries
LinkChoose deterministic paragraph plans
LinkChoose deterministic paragraph plans
breakParagraph evaluates its Paragraph argument through the ordinary call rules, then reads its item sequence and policies. Planning performs no input mutation, text shaping, external I/O, or random selection. The same ordered input and computation rules produce the same lines and scores.
Paragraph.items supplies measured BoxItem and GlueItem units with contiguous indices from zero. PenaltyItem entries refer to boundaries between those units. The planner uses these measurements and supplied penalties directly. It does not call classifyBreaks or insert a terminal penalty.
Paragraph.grid selects integer quantization at the computation boundary. Every public distance remains Length<Pt>. FixedPoint requires MilliPoint. KnuthPlass accepts either DistanceGrid. The ordinary checked length conversion applies before integer planning.
Policy validation precedes item validation. Geometry, the cost model and grid combination, justification values, and KnuthPlassPolicy are validated even when a chosen model does not use a policy field for scoring. Invalid configuration returns TypesetError.InvalidPolicy. Invalid unit indices, capacities, or penalty endpoints return TypesetError.InvalidInput.
A valid empty items array returns two empty plans with zero totalCost and zero breakOpportunityCount. This case still validates the policies. Each empty plan reports its selected grid and None() for boundedFillFeasible.
For nonempty input, the planner orders penalties by increasing unitEnd and preserves supplied order at equal boundaries. Allowed and Forced entries are candidates. Forbidden entries are excluded individually. Duplicate candidates remain distinct. A Forced entry requires the plan to visit its boundary, where another eligible entry may be selected.
No candidates returns TypesetError.NoBreakOpportunities. The planner constructs the greedy baseline before the optimized search. Failure to complete that baseline returns TypesetError.NoGreedyPlan. A completed baseline followed by an unsuccessful optimized search returns TypesetError.NoPlan. An Err result contains no partial ParagraphResult.
For FixedPoint, greedy chooses the farthest raw width that fits the next target before the first overwide candidate or Forced boundary. If the first candidate is already overwide, greedy chooses it to advance. For KnuthPlass, greedy chooses the last ratio-admissible candidate up to the next Forced boundary. Every chosen boundary advances past the previous one.
FixedPoint optimization starts with the preceding 80 candidates at each destination. It extends the search backward while the preceding span fits the larger base target plus available shrink and one grid unit. It retains the least score for each boundary and semantic state. It admits at most two consecutive LatinSoftHyphen breaks.
FixedPoint optimized admission uses trimmed text width plus the selected penalty width. The width limit is the target plus available shrink for a nonfinal line, with one grid unit of rounding allowance. A line containing one unit can exceed this limit so an indivisible unit can make progress. Greedy reports the same limit but selects candidates using its raw width rule.
With FixedPoint, a justified mode, and Some(latinSpacing), optimization first searches for a complete plan whose lines satisfy the bounded fill check. It prefers that plan when found. Otherwise it repeats the search without that check. This preference can select a plan with a higher totalCost than the greedy plan.
KnuthPlass optimization considers every preceding candidate and retains each distinct line geometry bucket, fitness class, and flagged state at a boundary. FixedPoint also retains its soft hyphen streak. State buckets distinguish drop cap lines and collapse after the inset ends.
Equal scores retain the first visited predecessor. Candidates are visited in boundary order, with supplied order at equal boundaries. States are visited by increasing line geometry bucket, soft hyphen streak, fitness class, and then unflagged before flagged. Final selection uses the same first-on-equal rule.
The optimized field reports the selected model search and admission policy. The greedy field reports its baseline from the same input. Each reported cost belongs to the plan selected by these candidate, state, and admission rules. Ordinary checked arithmetic faults remain faults and are not converted into a TypesetError value.
Why
Applications need reproducible line boundaries and a clear choice between a bounded fixed point search and a Knuth Plass state search. Reporting both selected plans preserves the baseline for inspection. Keeping policy failure, missing candidates, and unsuccessful searches distinct lets a caller decide which input to revise.
Source evidence
- compiler/crates/topaz_resolve/src/std/typeset/paragraph.tpz at
f3807a34248e· 1-106 - compiler/crates/topaz_resolve/src/std/typeset/greedy.tpz at
f3807a34248e· 1-36 - compiler/crates/topaz_resolve/src/std/typeset/admission.tpz at
f3807a34248e· 1-36 - compiler/crates/topaz_resolve/src/std/typeset/measure.tpz at
f3807a34248e· 27-87 - compiler/crates/topaz_resolve/src/std/typeset/line.tpz at
f3807a34248e· 11-27 - compiler/crates/topaz_resolve/src/std/typeset/wide.tpz at
f3807a34248e· 1-28 -
topaz.stdlib.contract.typeset-paragraph-planningatworking-tree
Plan a paragraph through its supplied boundaries
Linkimport std.typeset as tsimport std.iolet items: Array<ts.Item> = [ts.Item.BoxItem(ts.Box { unitIndex: 0, text: "a", width: 1pt, trackingAfter: 0pt }),ts.Item.BoxItem(ts.Box { unitIndex: 1, text: "a", width: 1pt, trackingAfter: 0pt }),ts.Item.PenaltyItem(ts.Penalty { unitEnd: 2, width: 0pt, rule: ts.BreakRule.Allowed(0), kind: ts.BreakKind.LatinSpace(), flagged: false }),ts.Item.BoxItem(ts.Box { unitIndex: 2, text: "a", width: 1pt, trackingAfter: 0pt }),ts.Item.BoxItem(ts.Box { unitIndex: 3, text: "a", width: 1pt, trackingAfter: 0pt }),ts.Item.PenaltyItem(ts.Penalty { unitEnd: 4, width: 0pt, rule: ts.BreakRule.Forced(), kind: ts.BreakKind.ForcedEnd(), flagged: false })]let input = ts.Paragraph {grid: ts.DistanceGrid.MilliPoint(),items: items,geometry: ts.LineGeometry { bodyTarget: 2pt, firstTarget: 2pt, dropCapSpan: 0, dropCapInset: 0pt },justification: ts.JustificationPolicy {mode: ts.JustificationMode.Unjustified(), minGapCount: 0,minLineWidthRatioM: 0, minFinalLineWidthRatioM: None(),maxAdjustment: 0pt, maxGapAdjustment: 0pt, maxGapRatioR: 0,latinSpacing: None(), cjkStretchRatio: 0.0},costModel: ts.CostModel.FixedPoint(),knuthPlass: ts.KnuthPlassPolicy { toleranceR: 100000000, linePenalty: 10, fitnessDemerit: 0, flaggedDemerit: 0, finalFlaggedDemerit: 0 }}match (ts.breakParagraph(input)) {case Ok(result) => {for line in (result.optimized.lines) {io.writeLine("{line.start} {line.endExclusive}")}io.writeLine("{result.greedy.lines.length} {result.breakOpportunityCount}")}case Err(_) => io.writeLine("unexpected error")}
0 2 2 4 2 2
Expected result
Expected result
Execution completes. Exit code 0.
0 22 42 2
Source evidence
- compiler/crates/topaz_resolve/src/std/typeset/paragraph.tpz at
f3807a34248e· 1-106 - compiler/crates/topaz_resolve/src/std/typeset/greedy.tpz at
f3807a34248e· 1-36 - compiler/crates/topaz_resolve/src/std/typeset/admission.tpz at
f3807a34248e· 1-36 - compiler/crates/topaz_resolve/src/std/typeset/measure.tpz at
f3807a34248e· 27-87 - compiler/crates/topaz_resolve/src/std/typeset/line.tpz at
f3807a34248e· 11-27 - compiler/crates/topaz_resolve/src/std/typeset/wide.tpz at
f3807a34248e· 1-28 -
topaz.stdlib.contract.typeset-paragraph-planningatworking-tree
Plan a valid empty paragraph
Linkimport std.typeset as tsimport std.iolet items: Array<ts.Item> = []let input = ts.Paragraph {grid: ts.DistanceGrid.MilliPoint(),items: items,geometry: ts.LineGeometry { bodyTarget: 10pt, firstTarget: 10pt, dropCapSpan: 0, dropCapInset: 0pt },justification: ts.JustificationPolicy {mode: ts.JustificationMode.Unjustified(), minGapCount: 0,minLineWidthRatioM: 0, minFinalLineWidthRatioM: None(),maxAdjustment: 0pt, maxGapAdjustment: 0pt, maxGapRatioR: 0,latinSpacing: None(), cjkStretchRatio: 0.0},costModel: ts.CostModel.FixedPoint(),knuthPlass: ts.KnuthPlassPolicy { toleranceR: 100000000, linePenalty: 10, fitnessDemerit: 0, flaggedDemerit: 0, finalFlaggedDemerit: 0 }}match (ts.breakParagraph(input)) {case Ok(result) => {io.writeLine("{result.optimized.lines.length} {result.greedy.lines.length}")io.writeLine("{result.optimized.totalCost} {result.greedy.totalCost} {result.breakOpportunityCount}")}case Err(_) => io.writeLine("unexpected error")}
0 0 0 0 0
Expected result
Expected result
Execution completes. Exit code 0.
0 00 0 0
Source evidence
- compiler/crates/topaz_resolve/src/std/typeset/paragraph.tpz at
f3807a34248e· 1-106 - compiler/crates/topaz_resolve/src/std/typeset/greedy.tpz at
f3807a34248e· 1-36 - compiler/crates/topaz_resolve/src/std/typeset/admission.tpz at
f3807a34248e· 1-36 - compiler/crates/topaz_resolve/src/std/typeset/measure.tpz at
f3807a34248e· 27-87 - compiler/crates/topaz_resolve/src/std/typeset/line.tpz at
f3807a34248e· 11-27 - compiler/crates/topaz_resolve/src/std/typeset/wide.tpz at
f3807a34248e· 1-28 -
topaz.stdlib.contract.typeset-paragraph-planningatworking-tree
Report absent break opportunities
Linkimport std.typeset as tsimport std.iolet items: Array<ts.Item> = [ts.Item.BoxItem(ts.Box { unitIndex: 0, text: "a", width: 1pt, trackingAfter: 0pt })]let input = ts.Paragraph {grid: ts.DistanceGrid.MilliPoint(),items: items,geometry: ts.LineGeometry { bodyTarget: 10pt, firstTarget: 10pt, dropCapSpan: 0, dropCapInset: 0pt },justification: ts.JustificationPolicy {mode: ts.JustificationMode.Unjustified(), minGapCount: 0,minLineWidthRatioM: 0, minFinalLineWidthRatioM: None(),maxAdjustment: 0pt, maxGapAdjustment: 0pt, maxGapRatioR: 0,latinSpacing: None(), cjkStretchRatio: 0.0},costModel: ts.CostModel.FixedPoint(),knuthPlass: ts.KnuthPlassPolicy { toleranceR: 100000000, linePenalty: 10, fitnessDemerit: 0, flaggedDemerit: 0, finalFlaggedDemerit: 0 }}match (ts.breakParagraph(input)) {case Err(NoBreakOpportunities()) => io.writeLine("NoBreakOpportunities")case _ => io.writeLine("unexpected result")}
NoBreakOpportunities
Expected result
Expected result
Execution completes. Exit code 0.
NoBreakOpportunities
Source evidence
- compiler/crates/topaz_resolve/src/std/typeset/paragraph.tpz at
f3807a34248e· 1-106 - compiler/crates/topaz_resolve/src/std/typeset/greedy.tpz at
f3807a34248e· 1-36 - compiler/crates/topaz_resolve/src/std/typeset/admission.tpz at
f3807a34248e· 1-36 - compiler/crates/topaz_resolve/src/std/typeset/measure.tpz at
f3807a34248e· 27-87 - compiler/crates/topaz_resolve/src/std/typeset/line.tpz at
f3807a34248e· 11-27 - compiler/crates/topaz_resolve/src/std/typeset/wide.tpz at
f3807a34248e· 1-28 -
topaz.stdlib.contract.typeset-paragraph-planningatworking-tree
Report a missing greedy completion
Linkimport std.typeset as tsimport std.iolet items: Array<ts.Item> = [ts.Item.BoxItem(ts.Box { unitIndex: 0, text: "a", width: 1pt, trackingAfter: 0pt }),ts.Item.BoxItem(ts.Box { unitIndex: 1, text: "a", width: 1pt, trackingAfter: 0pt }),ts.Item.PenaltyItem(ts.Penalty { unitEnd: 1, width: 0pt, rule: ts.BreakRule.Allowed(0), kind: ts.BreakKind.ForcedEnd(), flagged: false })]let input = ts.Paragraph {grid: ts.DistanceGrid.MilliPoint(),items: items,geometry: ts.LineGeometry { bodyTarget: 10pt, firstTarget: 10pt, dropCapSpan: 0, dropCapInset: 0pt },justification: ts.JustificationPolicy {mode: ts.JustificationMode.Unjustified(), minGapCount: 0,minLineWidthRatioM: 0, minFinalLineWidthRatioM: None(),maxAdjustment: 0pt, maxGapAdjustment: 0pt, maxGapRatioR: 0,latinSpacing: None(), cjkStretchRatio: 0.0},costModel: ts.CostModel.FixedPoint(),knuthPlass: ts.KnuthPlassPolicy { toleranceR: 100000000, linePenalty: 10, fitnessDemerit: 0, flaggedDemerit: 0, finalFlaggedDemerit: 0 }}match (ts.breakParagraph(input)) {case Err(NoGreedyPlan()) => io.writeLine("NoGreedyPlan")case _ => io.writeLine("unexpected result")}
NoGreedyPlan
Expected result
Expected result
Execution completes. Exit code 0.
NoGreedyPlan
Source evidence
- compiler/crates/topaz_resolve/src/std/typeset/paragraph.tpz at
f3807a34248e· 1-106 - compiler/crates/topaz_resolve/src/std/typeset/greedy.tpz at
f3807a34248e· 1-36 - compiler/crates/topaz_resolve/src/std/typeset/admission.tpz at
f3807a34248e· 1-36 - compiler/crates/topaz_resolve/src/std/typeset/measure.tpz at
f3807a34248e· 27-87 - compiler/crates/topaz_resolve/src/std/typeset/line.tpz at
f3807a34248e· 11-27 - compiler/crates/topaz_resolve/src/std/typeset/wide.tpz at
f3807a34248e· 1-28 -
topaz.stdlib.contract.typeset-paragraph-planningatworking-tree
Report three forced soft hyphens in a row
Linkimport std.typeset as tsimport std.iolet items: Array<ts.Item> = [ts.Item.BoxItem(ts.Box { unitIndex: 0, text: "a", width: 1pt, trackingAfter: 0pt }),ts.Item.PenaltyItem(ts.Penalty { unitEnd: 1, width: 0pt, rule: ts.BreakRule.Forced(), kind: ts.BreakKind.LatinSoftHyphen(), flagged: false }),ts.Item.BoxItem(ts.Box { unitIndex: 1, text: "a", width: 1pt, trackingAfter: 0pt }),ts.Item.PenaltyItem(ts.Penalty { unitEnd: 2, width: 0pt, rule: ts.BreakRule.Forced(), kind: ts.BreakKind.LatinSoftHyphen(), flagged: false }),ts.Item.BoxItem(ts.Box { unitIndex: 2, text: "a", width: 1pt, trackingAfter: 0pt }),ts.Item.PenaltyItem(ts.Penalty { unitEnd: 3, width: 0pt, rule: ts.BreakRule.Forced(), kind: ts.BreakKind.LatinSoftHyphen(), flagged: false })]let input = ts.Paragraph {grid: ts.DistanceGrid.MilliPoint(),items: items,geometry: ts.LineGeometry { bodyTarget: 1pt, firstTarget: 1pt, dropCapSpan: 0, dropCapInset: 0pt },justification: ts.JustificationPolicy {mode: ts.JustificationMode.Unjustified(), minGapCount: 0,minLineWidthRatioM: 0, minFinalLineWidthRatioM: None(),maxAdjustment: 0pt, maxGapAdjustment: 0pt, maxGapRatioR: 0,latinSpacing: None(), cjkStretchRatio: 0.0},costModel: ts.CostModel.FixedPoint(),knuthPlass: ts.KnuthPlassPolicy { toleranceR: 100000000, linePenalty: 10, fitnessDemerit: 0, flaggedDemerit: 0, finalFlaggedDemerit: 0 }}match (ts.breakParagraph(input)) {case Err(NoPlan()) => io.writeLine("NoPlan")case _ => io.writeLine("unexpected result")}
NoPlan
Expected result
Expected result
Execution completes. Exit code 0.
NoPlan
Source evidence
- compiler/crates/topaz_resolve/src/std/typeset/paragraph.tpz at
f3807a34248e· 1-106 - compiler/crates/topaz_resolve/src/std/typeset/greedy.tpz at
f3807a34248e· 1-36 - compiler/crates/topaz_resolve/src/std/typeset/admission.tpz at
f3807a34248e· 1-36 - compiler/crates/topaz_resolve/src/std/typeset/measure.tpz at
f3807a34248e· 27-87 - compiler/crates/topaz_resolve/src/std/typeset/line.tpz at
f3807a34248e· 11-27 - compiler/crates/topaz_resolve/src/std/typeset/wide.tpz at
f3807a34248e· 1-28 -
topaz.stdlib.contract.typeset-paragraph-planningatworking-tree
Distinguish invalid data from unavailable plans
LinkDistinguish invalid data from unavailable plans
TypesetError values are returned in Err by the typesetting operations that declare them. InvalidInput carries explanatory text for invalid measured data or boundary structure. InvalidPolicy carries explanatory text for an invalid algorithm configuration.
The string payload describes a cause. Programs distinguish failure categories by matching the variant rather than comparing library message text. Constructing an error value directly preserves its supplied string.
NoBreakOpportunities means a nonempty paragraph has no selectable penalty candidate after validation and filtering. It does not mean that the selected cost model searched unsuccessfully.
NoGreedyPlan means a validated paragraph has selectable candidates but its deterministic greedy baseline cannot reach the final unit. NoPlan means that baseline completed but the selected optimization search found no permitted complete plan.
A successful empty paragraph has two empty plans and zero candidates under the paragraph contract. It is not a missing-opportunity failure.
breakParagraph validates policy configuration before measured items. It then checks candidates, builds the greedy plan, and searches for an optimized plan in that order. The first failing stage determines the returned variant.
The policy stages check geometry, the cost model and grid combination, justification settings, and KnuthPlass settings. Item validation follows source encounter order and checks collected penalty endpoints after the measured units.
classifyBreaks applies its input and break-policy validation rules. The shared error variants do not impose paragraph validation order on break classification.
An Err contains no partial ParagraphResult and does not mutate the supplied input. Previously completed argument effects remain completed. A failure while evaluating an argument keeps its ordinary language diagnostic and prevents the typesetting call.
Why
Applications can repair malformed data, choose another policy, or report the absence of a plan when these outcomes stay distinct. Named variants provide that decision without relying on diagnostic wording or silently substituting a different algorithm.
Source evidence
- compiler/crates/topaz_resolve/src/std/typeset/model.tpz at
v5.21.3· 6 - compiler/crates/topaz_resolve/src/std/typeset/admission.tpz at
v5.21.3· 1 - compiler/crates/topaz_resolve/src/std/typeset/measure.tpz at
v5.21.3· 27 - compiler/crates/topaz_resolve/src/std/typeset/greedy.tpz at
v5.21.3· 1 - compiler/crates/topaz_resolve/src/std/typeset/paragraph.tpz at
v5.21.3· 87 - compiler/crates/topaz_resolve/src/std/typeset/breaks.tpz at
v5.21.3· 1 -
topaz.stdlib.contract.typeset-errorsatworking-tree
Preserve explanatory error payloads
Linkimport std.typeset as tsimport std.iolet failures: Array<ts.TypesetError> = [ts.TypesetError.InvalidInput("measured unit"),ts.TypesetError.InvalidPolicy("line target")]for failure in (failures) {match (failure) {case InvalidInput(message) => io.writeLine("input {message}")case InvalidPolicy(message) => io.writeLine("policy {message}")case _ => io.writeLine("unexpected variant")}}
input measured unit policy line target
Expected result
Expected result
Execution completes. Exit code 0.
input measured unitpolicy line target
Source evidence
- compiler/crates/topaz_resolve/src/std/typeset/model.tpz at
v5.21.3· 6 - compiler/crates/topaz_resolve/src/std/typeset/admission.tpz at
v5.21.3· 1 - compiler/crates/topaz_resolve/src/std/typeset/measure.tpz at
v5.21.3· 27 - compiler/crates/topaz_resolve/src/std/typeset/greedy.tpz at
v5.21.3· 1 - compiler/crates/topaz_resolve/src/std/typeset/paragraph.tpz at
v5.21.3· 87 - compiler/crates/topaz_resolve/src/std/typeset/breaks.tpz at
v5.21.3· 1 -
topaz.stdlib.contract.typeset-errorsatworking-tree
Report an invalid paragraph policy before an invalid unit index
Linkimport std.typeset as tsimport std.iolet items: Array<ts.Item> = [ts.Item.BoxItem(ts.Box { unitIndex: 1, text: "a", width: 1pt, trackingAfter: 0pt }),ts.Item.PenaltyItem(ts.Penalty { unitEnd: 1, width: 0pt, rule: ts.BreakRule.Forced(), kind: ts.BreakKind.ForcedEnd(), flagged: false })]let input = ts.Paragraph {grid: ts.DistanceGrid.MilliPoint(),items: items,geometry: ts.LineGeometry { bodyTarget: 0pt, firstTarget: 0pt, dropCapSpan: 0, dropCapInset: 0pt },justification: ts.JustificationPolicy {mode: ts.JustificationMode.Unjustified(), minGapCount: 0,minLineWidthRatioM: 0, minFinalLineWidthRatioM: None(),maxAdjustment: 0pt, maxGapAdjustment: 0pt, maxGapRatioR: 0,latinSpacing: None(), cjkStretchRatio: 0.0},costModel: ts.CostModel.FixedPoint(),knuthPlass: ts.KnuthPlassPolicy { toleranceR: 100000000, linePenalty: 10, fitnessDemerit: 0, flaggedDemerit: 0, finalFlaggedDemerit: 0 }}match (ts.breakParagraph(input)) {case Err(InvalidPolicy(_)) => io.writeLine("InvalidPolicy")case _ => io.writeLine("unexpected result")}
InvalidPolicy
Expected result
Expected result
Execution completes. Exit code 0.
InvalidPolicy
Source evidence
- compiler/crates/topaz_resolve/src/std/typeset/model.tpz at
v5.21.3· 6 - compiler/crates/topaz_resolve/src/std/typeset/admission.tpz at
v5.21.3· 1 - compiler/crates/topaz_resolve/src/std/typeset/measure.tpz at
v5.21.3· 27 - compiler/crates/topaz_resolve/src/std/typeset/greedy.tpz at
v5.21.3· 1 - compiler/crates/topaz_resolve/src/std/typeset/paragraph.tpz at
v5.21.3· 87 - compiler/crates/topaz_resolve/src/std/typeset/breaks.tpz at
v5.21.3· 1 -
topaz.stdlib.contract.typeset-errorsatworking-tree