When bounds overflow
A pattern analyzer panics before it can reject an enormous expression.
What’s going wrong
A pattern analyzer combines length ranges for concatenated fragments. Very large fragments panic in checked builds. Turning overflow checks off can instead produce misleading bounds.
Each input line is `minimum maximum`, both u32 decimal values, or `minimum *` for an unknown upper bound. Each finite maximum is at least its minimum. Combine all fragments. The reported minimum is a conservative u32 lower bound: clamp it at 4294967295 if the actual minimum is larger. A finite maximum must never underestimate the actual value; print `*` if it is unknown or not representable as u32. Empty input represents an empty pattern and prints `0 0`. Output is one line `minimum maximum`.
The sandbox compiles with overflow checks enabled. Fix the calculation without panics and retain the distinction between lower and upper bounds.
Expected behavior
Lower bounds saturate conservatively. Upper bounds remain exact when representable and become unknown on overflow or any unknown constituent.
Reproduction
4294967290 4294967295 10 20
4294967295 *
2 4 3 8
5 12
Before you begin
- Option and pattern matching
- u32 arithmetic
- Conservative lower/upper bounds
Need a nudge?
Reveal one investigation hint at a time. Try each clue before opening the next.
Read the report, then sign in to start your investigation.