typst_analyzer/typst_lang/
semantic_analysis.rs1use thiserror::Error;
9
10use super::span::Span;
11
12#[derive(Error, Debug)]
13pub enum SemanticError {
14 #[error("Undefined variable {name}")]
15 UndefinedVariable { name: String, span: Span },
16 #[error("Expect element type: {expect_type}, but got {actual_type}")]
17 ImConsistentArrayType {
18 expect_type: String,
19 actual_type: String,
20 span: Span,
21 },
22}
23
24impl SemanticError {
25 pub fn span(&self) -> Span {
26 match self {
27 SemanticError::UndefinedVariable { span, .. } => span.clone(),
28 SemanticError::ImConsistentArrayType { span, .. } => span.clone(),
29 }
30 }
31}
32
33pub type Result<T> = std::result::Result<T, SemanticError>;
34
35pub enum IndentType {}