microcad_lang/resolve/
resolve_error.rs1use thiserror::Error;
7
8use crate::{diag::*, parse::*, syntax::*};
9
10#[derive(Debug, Error)]
12pub enum ResolveError {
13 #[error("Parse Error: {0}")]
15 ParseError(#[from] ParseError),
16
17 #[error("Could not find a file with hash {0}")]
19 UnknownHash(u64),
20
21 #[error("Hash is zero")]
23 NulHash,
24
25 #[error("External symbol `{0}` not found")]
27 ExternalSymbolNotFound(QualifiedName),
28
29 #[error("External path `{0}` not found")]
31 ExternalPathNotFound(std::path::PathBuf),
32
33 #[error("Could not find a file with path {0}")]
35 FileNotFound(std::path::PathBuf),
36
37 #[error("Symbol {0} not found while resolving.")]
39 SymbolNotFound(QualifiedName),
40
41 #[error("Symbol {0} must be loaded from {1}")]
43 SymbolMustBeLoaded(QualifiedName, std::path::PathBuf),
44
45 #[error("Symbol {0} is not a value")]
47 NotAValue(QualifiedName),
48
49 #[error("Declaration of {0} not allowed within {1}")]
51 DeclNotAllowed(Identifier, QualifiedName),
52
53 #[error("Ambiguous external module files found {0:?}")]
55 AmbiguousExternals(Vec<std::path::PathBuf>),
56
57 #[error("Symbol {0} already defined")]
59 SymbolAlreadyDefined(QualifiedName),
60
61 #[error("Ambiguous symbol found: {0}")]
63 AmbiguousSymbol(QualifiedName, QualifiedNames),
64
65 #[error("{0}")]
67 ScanDirError(#[from] scan_dir::Error),
68
69 #[error("Invalid path: {0:?}")]
71 InvalidPath(std::path::PathBuf),
72
73 #[error("Diagnostic error: {0}")]
75 DiagError(#[from] DiagError),
76
77 #[error("{0} is not available within {1}")]
79 StatementNotSupported(String, String),
80
81 #[error("Resolve failed")]
83 ResolveCheckFailed,
84
85 #[error("Symbol {0} is private")]
87 SymbolIsPrivate(QualifiedName),
88
89 #[error("{0}")]
91 IoError(#[from] std::io::Error),
92
93 #[error(
95 "Source of module '{0}' could not be found in {1:?} (expecting a file '{0}.µcad' or '{0}/mod.µcad')"
96 )]
97 SourceFileNotFound(Identifier, std::path::PathBuf),
98
99 #[error("Wrong lookup target")]
101 WrongTarget,
102
103 #[error("Statement not allowed within workbenches")]
105 IllegalWorkbenchStatement,
106
107 #[error("Code between initializers is not allowed")]
109 CodeBetweenInitializers,
110
111 #[error("Statement not allowed prior initializers")]
113 StatementNotAllowedPriorInitializers,
114}
115
116pub type ResolveResult<T> = std::result::Result<T, ResolveError>;