genRange crashes with ClOpen when lower bound equals upper bound

Open Beginner friendly
#166 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
haskell
Domain
testing-qa

Research direction

Read src/Codec/CBOR/Cuddle/CBOR/Gen.hs, starting at genRange and its range helper, and reproduce the empty 5...5 case with ClOpen bounds. Validate the adjusted range before choose or antiChoose, and consider the issue resolved when empty ranges produce a clear error instead of an invalid-range crash.

Written by the indexing model from the issue text.

Description

bug

Description

genRange can crash with an invalid choose range when the lower bound equals the upper bound and bounds are ClOpen.

Location

src/Codec/CBOR/Cuddle/CBOR/Gen.hs, genRange function

Details

When a == b and the range bound is ClOpen, the range helper computes (x, pred y), producing an upper bound strictly less than the lower bound. This causes choose/antiChoose to crash with an invalid range.

For example, a CDDL range like 5...5 (exclusive on both ends) results in an empty range that choose cannot handle.

Suggested fix

Validate that the range is non-empty after applying bounds, and emit a clear error message for empty ranges instead of crashing inside choose.

Dominant language
Haskell
Stars
8
Forks
5
Avg merge
3d 12h
Merged PRs (30d)
4

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from IntersectMBO/cuddle

All issues in IntersectMBO/cuddle

Similar issues

More Haskell issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.