microcad_lang/resolve/
resolve_error.rs

1// Copyright © 2024-2025 The µcad authors <info@ucad.xyz>
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4//! Resolve error
5
6use thiserror::Error;
7
8use crate::{parse::ParseError, src_ref::*, syntax::*};
9
10/// Resolve error.
11#[derive(Debug, Error)]
12pub enum ResolveError {
13    /// To do
14    #[error("Not implemented: {0}")]
15    Todo(String),
16
17    /// Parse Error.
18    #[error("Parse Error: {0}")]
19    ParseError(#[from] ParseError),
20
21    /// Can't find a project file by hash.
22    #[error("Could not find a file with hash {0}")]
23    UnknownHash(u64),
24
25    /// Hash is zero
26    #[error("Hash is zero")]
27    NulHash,
28
29    /// Name of external symbol is unknown.
30    #[error("External symbol `{0}` not found")]
31    ExternalSymbolNotFound(QualifiedName),
32
33    /// Path of external file is unknown.
34    #[error("External path `{0}` not found")]
35    ExternalPathNotFound(std::path::PathBuf),
36
37    /// Can't find a project file by it's path.
38    #[error("Could not find a file with path {0}")]
39    FileNotFound(std::path::PathBuf),
40
41    /// Symbol not found.
42    #[error("Symbol {0} not found.")]
43    SymbolNotFound(QualifiedName),
44
45    /// Symbol not found (retry to load from external).
46    #[error("Symbol {0} must be loaded from {1}")]
47    SymbolMustBeLoaded(QualifiedName, std::path::PathBuf),
48
49    /// Property is not allowed at this place
50    #[error("Defining a property is not allowed here ({0})")]
51    PropertyNotAllowed(SrcRef),
52
53    /// Symbol is not a value
54    #[error("Symbol {0} is not a value")]
55    NotAValue(QualifiedName),
56
57    /// Declaration of property not allowed here
58    #[error("Declaration of {0} not allowed within {1}")]
59    DeclNotAllowed(Identifier, QualifiedName),
60}
61
62/// Result type of any resolve.
63pub type ResolveResult<T> = std::result::Result<T, ResolveError>;