input-output-hk / input-output-hk/cuddle

genRange crashes with ClOpen when lower bound equals upper bound

Open
#166 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Haskell
Stars
7
Forks
5
PR merge metrics
No merged PRs in 30d

Description

## 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`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.