shuttle-hq / synth

The Declarative Data Generator
https://www.getsynth.com/
Apache License 2.0
1.39k stars 109 forks source link

`unreachable` triggered on weightless single-variant categorical #197

Closed llogiq closed 3 years ago

llogiq commented 3 years ago

Describe the bug WIth a categorical containing only one variant with a weight of 0, we happen upon an unreachable error.

To Reproduce Steps to reproduce the behavior:

  1. Schema (if applicable)
    {
    "type": "array",
    "length": 1,
    "content": {
        "type": "object",
        "cat": {
            "type": "string",
            "categorical": {
                "empty": 0
            }
        }
    }
    }
  2. See error
    thread 'main' panicked at 'internal error: entered unreachable code', /home/andre/projects/synth/core/src/schema/content/categorical.rs:82:9
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Expected behavior The single category should be used regardless of weight and also a warning about a single-variant categorical should be emitted.

Environment (please complete the following information):