1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// =============================================================================
// Copyright (c) 2025 - 2026 Haixing Hu.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0.
// =============================================================================
//! Errors that explain why runtime values cannot be numerically ordered.
use qubit_datatype::DataType;
use thiserror::Error;
/// Describes why two [`crate::Value`] instances cannot be numerically ordered.
#[must_use]
#[derive(Debug, Clone, PartialEq, Eq, Error)]
#[non_exhaustive]
pub enum NumericComparisonError {
/// The left operand is unset but retains a declared type.
#[error("left value is missing: declared type is {declared}")]
LeftMissing {
/// Declared runtime type of the unset left operand.
declared: DataType,
},
/// The right operand is unset but retains a declared type.
#[error("right value is missing: declared type is {declared}")]
RightMissing {
/// Declared runtime type of the unset right operand.
declared: DataType,
},
/// The concrete left operand is not numeric.
#[error("left value is not numeric: {actual}")]
LeftNotNumeric {
/// Actual runtime type of the left operand.
actual: DataType,
},
/// The concrete right operand is not numeric.
#[error("right value is not numeric: {actual}")]
RightNotNumeric {
/// Actual runtime type of the right operand.
actual: DataType,
},
/// Only the left operand is NaN.
#[error("left value is NaN")]
LeftNaN,
/// Only the right operand is NaN.
#[error("right value is NaN")]
RightNaN,
/// Both operands are NaN.
#[error("both values are NaN")]
BothNaN,
}