Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions source/compiler/qsc/src/interpret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,17 @@ pub enum Error {
#[diagnostic(transparent)]
Circuit(#[from] qsc_circuit::Error),
#[error("entry point not found")]
#[diagnostic(code("Qsc.Interpret.NoEntryPoint"))]
#[diagnostic(code("Qdk.Qsc.Interpret.NoEntryPoint"))]
NoEntryPoint,
#[error("unsupported runtime capabilities for code generation")]
#[diagnostic(code("Qsc.Interpret.UnsupportedRuntimeCapabilities"))]
#[diagnostic(code("Qdk.Qsc.Interpret.UnsupportedRuntimeCapabilities"))]
UnsupportedRuntimeCapabilities,
#[error("expression does not evaluate to an operation")]
#[diagnostic(code("Qsc.Interpret.NotAnOperation"))]
#[diagnostic(code("Qdk.Qsc.Interpret.NotAnOperation"))]
#[diagnostic(help("provide the name of a callable or a lambda expression"))]
NotAnOperation,
#[error("value is not a global callable")]
#[diagnostic(code("Qsc.Interpret.NotACallable"))]
#[diagnostic(code("Qdk.Qsc.Interpret.NotACallable"))]
NotACallable,
#[error("partial evaluation error")]
#[diagnostic(transparent)]
Expand Down
2 changes: 1 addition & 1 deletion source/compiler/qsc/src/interpret/circuit_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,7 @@ fn eval_method_result_comparison() {
.pop()
.expect("error should exist");

expect!["Qsc.Eval.ResultComparisonUnsupported"].assert_eq(
expect!["Qdk.Qsc.Eval.ResultComparisonUnsupported"].assert_eq(
&circuit_err
.code()
.expect("error code should exist")
Expand Down
6 changes: 3 additions & 3 deletions source/compiler/qsc_circuit/src/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ use thiserror::Error;
#[derive(Clone, Debug, Diagnostic, Error)]
pub enum Error {
#[error("expression does not evaluate to an operation that takes qubit parameters")]
#[diagnostic(code("Qsc.Circuit.NoCircuitForOperation"))]
#[diagnostic(code("Qdk.Qsc.Circuit.NoCircuitForOperation"))]
#[diagnostic(help(
"provide the name of a callable or a lambda expression that only takes qubits as parameters"
))]
NoQubitParameters,
#[error("cannot generate circuit for controlled invocation")]
#[diagnostic(code("Qsc.Circuit.ControlledUnsupported"))]
#[diagnostic(code("Qdk.Qsc.Circuit.ControlledUnsupported"))]
#[diagnostic(help(
"controlled invocations are not currently supported. consider wrapping the invocation in a lambda expression"
))]
ControlledUnsupported,
#[error("program has features that are unsupported for circuit diagrams: {0}")]
#[diagnostic(code("Qsc.Circuit.UnsupportedFeature"))]
#[diagnostic(code("Qdk.Qsc.Circuit.UnsupportedFeature"))]
UnsupportedFeature(String),
}

Expand Down
4 changes: 2 additions & 2 deletions source/compiler/qsc_data_structures/src/error/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ use thiserror::Error;
#[derive(Clone, Debug, Diagnostic, Error)]
enum TestError {
#[error("Error: {0}")]
#[diagnostic(code("Qsc.Test.Error.NoSpans"))]
#[diagnostic(code("Qdk.Qsc.Test.Error.NoSpans"))]
NoSpans(String),
#[error("Error: {0}")]
#[diagnostic(code("Qsc.Test.Error.TwoSpans"))]
#[diagnostic(code("Qdk.Qsc.Test.Error.TwoSpans"))]
TwoSpans(
String,
#[label("first label")] Span,
Expand Down
58 changes: 29 additions & 29 deletions source/compiler/qsc_eval/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,145 +61,145 @@ use val::{Qubit, update_functor_app};
#[derive(Clone, Debug, Diagnostic, Error)]
pub enum Error {
#[error("array too large")]
#[diagnostic(code("Qsc.Eval.ArrayTooLarge"))]
#[diagnostic(code("Qdk.Qsc.Eval.ArrayTooLarge"))]
ArrayTooLarge(#[label("this array has too many items")] PackageSpan),

#[error("callable already counted")]
#[diagnostic(help(
"counting for a given callable must be stopped before it can be started again"
))]
#[diagnostic(code("Qsc.Eval.CallableAlreadyCounted"))]
#[diagnostic(code("Qdk.Qsc.Eval.CallableAlreadyCounted"))]
CallableAlreadyCounted(#[label] PackageSpan),

#[error("callable not counted")]
#[diagnostic(help("counting for a given callable must be started before it can be stopped"))]
#[diagnostic(code("Qsc.Eval.CallableNotCounted"))]
#[diagnostic(code("Qdk.Qsc.Eval.CallableNotCounted"))]
CallableNotCounted(#[label] PackageSpan),

#[error("invalid array length: {0}")]
#[diagnostic(code("Qsc.Eval.InvalidArrayLength"))]
#[diagnostic(code("Qdk.Qsc.Eval.InvalidArrayLength"))]
InvalidArrayLength(i64, #[label("cannot be used as a length")] PackageSpan),

#[error("division by zero")]
#[diagnostic(code("Qsc.Eval.DivZero"))]
#[diagnostic(code("Qdk.Qsc.Eval.DivZero"))]
DivZero(#[label("cannot divide by zero")] PackageSpan),

#[error("empty range")]
#[diagnostic(code("Qsc.Eval.EmptyRange"))]
#[diagnostic(code("Qdk.Qsc.Eval.EmptyRange"))]
EmptyRange(#[label("the range cannot be empty")] PackageSpan),

#[error("value cannot be used as an index: {0}")]
#[diagnostic(code("Qsc.Eval.InvalidIndex"))]
#[diagnostic(code("Qdk.Qsc.Eval.InvalidIndex"))]
InvalidIndex(i64, #[label("invalid index")] PackageSpan),

#[error("integer too large for operation")]
#[diagnostic(code("Qsc.Eval.IntTooLarge"))]
#[diagnostic(code("Qdk.Qsc.Eval.IntTooLarge"))]
IntTooLarge(i64, #[label("this value is too large")] PackageSpan),

#[error("index out of range: {0}")]
#[diagnostic(code("Qsc.Eval.IndexOutOfRange"))]
#[diagnostic(code("Qdk.Qsc.Eval.IndexOutOfRange"))]
IndexOutOfRange(i64, #[label("out of range")] PackageSpan),

#[error("intrinsic callable `{0}` failed: {1}")]
#[diagnostic(code("Qsc.Eval.IntrinsicFail"))]
#[diagnostic(code("Qdk.Qsc.Eval.IntrinsicFail"))]
IntrinsicFail(String, String, #[label] PackageSpan),

#[error("invalid rotation angle: {0}")]
#[diagnostic(code("Qsc.Eval.InvalidRotationAngle"))]
#[diagnostic(code("Qdk.Qsc.Eval.InvalidRotationAngle"))]
InvalidRotationAngle(f64, #[label("invalid rotation angle")] PackageSpan),

#[error("negative integers cannot be used here: {0}")]
#[diagnostic(code("Qsc.Eval.InvalidNegativeInt"))]
#[diagnostic(code("Qdk.Qsc.Eval.InvalidNegativeInt"))]
InvalidNegativeInt(i64, #[label("invalid negative integer")] PackageSpan),

#[error("output failure")]
#[diagnostic(code("Qsc.Eval.OutputFail"))]
#[diagnostic(code("Qdk.Qsc.Eval.OutputFail"))]
OutputFail(#[label("failed to generate output")] PackageSpan),

#[error("qubits in invocation are not unique")]
#[diagnostic(code("Qsc.Eval.QubitUniqueness"))]
#[diagnostic(code("Qdk.Qsc.Eval.QubitUniqueness"))]
QubitUniqueness(#[label] PackageSpan),

#[error("qubit used after release")]
#[diagnostic(help(
"qubits should not be used after being released, which typically occurs when a qubit is used after it has gone out of scope"
))]
#[diagnostic(code("Qsc.Eval.QubitUsedAfterRelease"))]
#[diagnostic(code("Qdk.Qsc.Eval.QubitUsedAfterRelease"))]
QubitUsedAfterRelease(#[label] PackageSpan),

#[error("qubit double release")]
#[diagnostic(code("Qsc.Eval.QubitDoubleRelease"))]
#[diagnostic(code("Qdk.Qsc.Eval.QubitDoubleRelease"))]
QubitDoubleRelease(#[label("qubit has already been released")] PackageSpan),

#[error("qubits already counted")]
#[diagnostic(help("counting for qubits must be stopped before it can be started again"))]
#[diagnostic(code("Qsc.Eval.QubitsAlreadyCounted"))]
#[diagnostic(code("Qdk.Qsc.Eval.QubitsAlreadyCounted"))]
QubitsAlreadyCounted(#[label] PackageSpan),

#[error("qubits not counted")]
#[diagnostic(help("counting for qubits must be started before it can be stopped"))]
#[diagnostic(code("Qsc.Eval.QubitsNotCounted"))]
#[diagnostic(code("Qdk.Qsc.Eval.QubitsNotCounted"))]
QubitsNotCounted(#[label] PackageSpan),

#[error("qubits are not separable")]
#[diagnostic(help(
"subset of qubits provided as arguments must not be entangled with any qubits outside of the subset"
))]
#[diagnostic(code("Qsc.Eval.QubitsNotSeparable"))]
#[diagnostic(code("Qdk.Qsc.Eval.QubitsNotSeparable"))]
QubitsNotSeparable(#[label] PackageSpan),

#[error("range with step size of zero")]
#[diagnostic(code("Qsc.Eval.RangeStepZero"))]
#[diagnostic(code("Qdk.Qsc.Eval.RangeStepZero"))]
RangeStepZero(#[label("invalid range")] PackageSpan),

#[error("qubit arrays used in relabeling must be a permutation of the same set of qubits")]
#[diagnostic(help("ensure that each qubit is present exactly once in both arrays"))]
#[diagnostic(code("Qsc.Eval.RelabelingMismatch"))]
#[diagnostic(code("Qdk.Qsc.Eval.RelabelingMismatch"))]
RelabelingMismatch(#[label] PackageSpan),

#[error("Qubit{0} released while not in |0⟩ state")]
#[diagnostic(help(
"qubits should be returned to the |0⟩ state before being released to satisfy the assumption that allocated qubits start in the |0⟩ state"
))]
#[diagnostic(code("Qsc.Eval.ReleasedQubitNotZero"))]
#[diagnostic(code("Qdk.Qsc.Eval.ReleasedQubitNotZero"))]
ReleasedQubitNotZero(usize, #[label("Qubit{0}")] PackageSpan),

#[error("cannot compare measurement results")]
#[diagnostic(code("Qsc.Eval.ResultComparisonUnsupported"))]
#[diagnostic(code("Qdk.Qsc.Eval.ResultComparisonUnsupported"))]
#[diagnostic(help(
"comparing measurement results is not supported when performing circuit synthesis or base profile QIR generation"
))]
ResultComparisonUnsupported(#[label("cannot compare to result")] PackageSpan),

#[error("cannot compare measurement result from qubit loss")]
#[diagnostic(code("Qsc.Eval.ResultLossComparisonUnsupported"))]
#[diagnostic(code("Qdk.Qsc.Eval.ResultLossComparisonUnsupported"))]
#[diagnostic(help(
"use of a measurement result from a qubit that was lost is not supported, use `IsLossResult` to ensure the result is valid before using it in a comparison"
))]
ResultLossComparisonUnsupported(#[label("cannot compare result from qubit loss")] PackageSpan),

#[error("simulation error: {0}")]
#[diagnostic(code("Qsc.Eval.SimulationError"))]
#[diagnostic(code("Qdk.Qsc.Eval.SimulationError"))]
SimulationError(String, #[label("simulation error")] PackageSpan),

#[error("name is not bound")]
#[diagnostic(code("Qsc.Eval.UnboundName"))]
#[diagnostic(code("Qdk.Qsc.Eval.UnboundName"))]
UnboundName(#[label] PackageSpan),

#[error("unknown intrinsic `{0}`")]
#[diagnostic(code("Qsc.Eval.UnknownIntrinsic"))]
#[diagnostic(code("Qdk.Qsc.Eval.UnknownIntrinsic"))]
UnknownIntrinsic(
String,
#[label("callable has no implementation")] PackageSpan,
),

#[error("unsupported return type for intrinsic `{0}`")]
#[diagnostic(help("intrinsic callable return type should be `Unit`"))]
#[diagnostic(code("Qsc.Eval.UnsupportedIntrinsicType"))]
#[diagnostic(code("Qdk.Qsc.Eval.UnsupportedIntrinsicType"))]
UnsupportedIntrinsicType(String, #[label] PackageSpan),

#[error("program failed: {0}")]
#[diagnostic(code("Qsc.Eval.UserFail"))]
#[diagnostic(code("Qdk.Qsc.Eval.UserFail"))]
UserFail(String, #[label("explicit fail")] PackageSpan),
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ fn error_diagnostic_has_code() {
let code = error
.code()
.expect("DynamicCallable should have a diagnostic code");
assert_eq!(code.to_string(), "Qsc.Defunctionalize.DynamicCallable");
assert_eq!(code.to_string(), "Qdk.Qsc.Defunctionalize.DynamicCallable");
}

#[test]
Expand All @@ -528,7 +528,7 @@ fn error_recursive_specialization() {
.expect("RecursiveSpecialization should have a diagnostic code");
assert_eq!(
code.to_string(),
"Qsc.Defunctionalize.RecursiveSpecialization"
"Qdk.Qsc.Defunctionalize.RecursiveSpecialization"
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ pub enum Error {
/// branches exceeds `MULTI_CAP`, a conditional has mismatched Multi
/// variants, or a mutable callable variable is reassigned in a loop.
#[error("callable argument could not be resolved statically")]
#[diagnostic(code("Qsc.Defunctionalize.DynamicCallable"))]
#[diagnostic(code("Qdk.Qsc.Defunctionalize.DynamicCallable"))]
#[diagnostic(help("ensure all callable arguments are known at compile time"))]
DynamicCallable(#[label] Span),

Expand All @@ -411,7 +411,7 @@ pub enum Error {
/// received. The recursion guard in `specialize` rejects the duplicate
/// entry rather than looping indefinitely.
#[error("specialization leads to infinite recursion")]
#[diagnostic(code("Qsc.Defunctionalize.RecursiveSpecialization"))]
#[diagnostic(code("Qdk.Qsc.Defunctionalize.RecursiveSpecialization"))]
RecursiveSpecialization(#[label] Span),

/// Emitted when the analysis → specialize → rewrite fixpoint loop exits
Expand All @@ -423,7 +423,7 @@ pub enum Error {
#[error(
"defunctionalization did not converge within {0} iterations; {1} callable values remain"
)]
#[diagnostic(code("Qsc.Defunctionalize.FixpointNotReached"))]
#[diagnostic(code("Qdk.Qsc.Defunctionalize.FixpointNotReached"))]
#[diagnostic(help("consider reducing the nesting depth of higher-order function chains"))]
FixpointNotReached(usize, usize, #[label("remaining callable value")] Span),

Expand All @@ -434,7 +434,7 @@ pub enum Error {
#[error(
"higher-order function `{0}` generated {1} specializations, exceeding the warning threshold"
)]
#[diagnostic(code("Qsc.Defunctionalize.ExcessiveSpecializations"))]
#[diagnostic(code("Qdk.Qsc.Defunctionalize.ExcessiveSpecializations"))]
#[diagnostic(severity(warning))]
#[diagnostic(help(
"consider reducing the number of distinct callable arguments passed to this function"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ use crate::reachability;
#[derive(Clone, Debug, Diagnostic, Error)]
pub enum Error {
#[error("intrinsic callable `{0}` has unsupported parameter type `{1}`")]
#[diagnostic(code("Qsc.FirTransform.UnsupportedIntrinsicParamType"))]
#[diagnostic(code("Qdk.Qsc.FirTransform.UnsupportedIntrinsicParamType"))]
#[diagnostic(help(
"intrinsic callable parameters cannot be non-empty tuples or user-defined types"
))]
UnsupportedParamType(String, String, #[label("unsupported parameter type")] Span),

#[error("intrinsic callable `{0}` has unsupported return type `{1}`")]
#[diagnostic(code("Qsc.FirTransform.UnsupportedIntrinsicReturnType"))]
#[diagnostic(code("Qdk.Qsc.FirTransform.UnsupportedIntrinsicReturnType"))]
#[diagnostic(help(
"intrinsic callable return types cannot be non-empty tuples or user-defined types"
))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn unsupported_param_type_has_diagnostic_code() {
let code = error.code().expect("should have diagnostic code");
assert_eq!(
code.to_string(),
"Qsc.FirTransform.UnsupportedIntrinsicParamType"
"Qdk.Qsc.FirTransform.UnsupportedIntrinsicParamType"
);
}

Expand Down
6 changes: 3 additions & 3 deletions source/compiler/qsc_fir_transforms/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,12 @@ pub enum PipelineError {

/// A pinned item requested by a caller was not present in the FIR store.
#[error("pinned item {0} does not exist")]
#[diagnostic(code("Qsc.FirTransform.MissingPinnedItem"))]
#[diagnostic(code("Qdk.Qsc.FirTransform.MissingPinnedItem"))]
MissingPinnedItem(StoreItemId),

/// A pinned item requested by a caller was present but was not a callable.
#[error("pinned item {0} is not a callable")]
#[diagnostic(code("Qsc.FirTransform.PinnedItemNotCallable"))]
#[diagnostic(code("Qdk.Qsc.FirTransform.PinnedItemNotCallable"))]
PinnedItemNotCallable(StoreItemId),

/// The tuple-decompose <-> argument-promotion fixed-point loop did not converge within
Expand All @@ -167,7 +167,7 @@ pub enum PipelineError {
#[error(
"tuple-decompose/argument-promotion fixed-point loop did not converge within {0} rounds"
)]
#[diagnostic(code("Qsc.FirTransform.TupleDecomposeArgPromoteFixpointNotReached"))]
#[diagnostic(code("Qdk.Qsc.FirTransform.TupleDecomposeArgPromoteFixpointNotReached"))]
#[diagnostic(severity(Warning))]
TupleDecomposeArgPromoteFixpointNotReached(usize),
}
Expand Down
6 changes: 3 additions & 3 deletions source/compiler/qsc_fir_transforms/src/return_unify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub enum Error {
/// Return-slot selection could not prove that either Direct or
/// `ArrayBacked` lowering is valid for this return type.
#[error("cannot unify early returns of type `{0}`")]
#[diagnostic(code("Qsc.ReturnUnify.UnsupportedEarlyReturnType"))]
#[diagnostic(code("Qdk.Qsc.ReturnUnify.UnsupportedEarlyReturnType"))]
#[diagnostic(severity(Warning))]
#[diagnostic(help(
"the return type has no classical default and cannot be array-backed; \
Expand All @@ -101,7 +101,7 @@ pub enum Error {
/// `"simplify"`) identifies which loop did not converge. The IR remains
/// semantically valid, but the partial fold indicates a rule regression.
#[error("return-unification {0} did not reach a fixpoint")]
#[diagnostic(code("Qsc.ReturnUnify.FixpointNotReached"))]
#[diagnostic(code("Qdk.Qsc.ReturnUnify.FixpointNotReached"))]
#[diagnostic(severity(Warning))]
#[diagnostic(help(
"this is an internal compiler diagnostic; please file an issue \
Expand All @@ -112,7 +112,7 @@ pub enum Error {
/// A return appears inside a compound expression whose enclosing
/// expression has a type with no classical default.
#[error("cannot hoist `return` from a compound position of type `{0}`")]
#[diagnostic(code("Qsc.ReturnUnify.UnsupportedHoistContext"))]
#[diagnostic(code("Qdk.Qsc.ReturnUnify.UnsupportedHoistContext"))]
#[diagnostic(severity(Warning))]
#[diagnostic(help(
"the surrounding expression has a non-defaultable type; \
Expand Down
2 changes: 1 addition & 1 deletion source/compiler/qsc_fir_transforms/src/walk_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ pub(crate) fn classify_uses_in_block(
// A tuple-literal reassignment (`set local = (..)`) disqualifies the
// local from promotion, so it folds into `HardBlock`. For the only
// caller (parameter classification) it is also borrowck-unreachable:
// `Qsc.BorrowCk.Mutability` forbids assigning to a parameter.
// `Qdk.Qsc.BorrowCk.Mutability` forbids assigning to a parameter.
UseEvent::Decomposable | UseEvent::HardBlock => ParamUse::HardBlock,
UseEvent::WholeValueRead(id) => ParamUse::WholeValueRead(id),
});
Expand Down
4 changes: 2 additions & 2 deletions source/compiler/qsc_frontend/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub type Dependencies = [(PackageId, Option<Arc<str>>)];
pub struct Error(pub(super) ErrorKind);

impl Error {
/// If this is an unresolved-name error (diagnostic code `Qsc.Resolve.NotFound`),
/// If this is an unresolved-name error (diagnostic code `Qdk.Qsc.Resolve.NotFound`),
/// returns the unresolved name and the span where it appears, otherwise `None`.
///
/// This covers both a name that genuinely doesn't exist and a name that exists
Expand All @@ -109,7 +109,7 @@ impl Error {
}
}

/// If this is a type-mismatch error (diagnostic code `Qsc.TypeCk.TyMismatch`),
/// If this is a type-mismatch error (diagnostic code `Qdk.Qsc.TypeCk.TyMismatch`),
/// returns (expected, actual, span), otherwise `None`.
#[must_use]
pub fn ty_mismatch(&self) -> Option<(&typeck::TyInfo, &typeck::TyInfo, Span)> {
Expand Down
Loading
Loading