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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
use edlang_ast::{Ident, Span};
use edlang_ir::{TypeInfo, TypeKind};
use thiserror::Error;

use crate::DefId;

#[derive(Debug, Error, Clone)]
pub enum LoweringError {
    #[error("module {module:?} not found")]
    ModuleNotFound {
        span: Span,
        module: String,
        file_id: usize,
    },
    #[error("function {function:?} not found")]
    FunctionNotFound {
        span: Span,
        function: String,
        file_id: usize,
    },
    #[error("symbol {:?} not found", symbol.name)]
    ImportNotFound {
        module_span: Span,
        import_span: Span,
        symbol: Ident,
        file_id: usize,
    },
    #[error("trying to mutate a non-mutable reference")]
    BorrowNotMutable {
        span: Span,
        type_span: Option<Span>,
        name: String,
        file_id: usize,
    },
    #[error("unrecognized type {name}")]
    UnrecognizedType {
        span: Span,
        name: String,
        file_id: usize,
    },
    #[error("id not found")]
    IdNotFound {
        span: Span,
        id: DefId,
        file_id: usize,
    },
    #[error("feature not yet implemented: {message}")]
    NotYetImplemented {
        span: Span,
        message: &'static str,
        file_id: usize,
    },
    #[error("unexpected type")]
    UnexpectedType {
        span: Span,
        found: TypeKind,
        expected: TypeInfo,
        file_id: usize,
    },
    #[error("use of underclared variable {name:?}")]
    UseOfUndeclaredVariable {
        span: Span,
        name: String,
        file_id: usize,
    },
    #[error("parameter count mismatch to function call")]
    ParamCountMismatch {
        span: Span,
        has_args: usize,
        needs: usize,
        file_id: usize,
    },
    #[error("can't mutate this value because it's not declared mutable")]
    NotMutable {
        span: Span,
        declare_span: Option<Span>,
        file_id: usize,
    },
    #[error("can't take a mutable borrow to this value because it's not declared mutable")]
    CantTakeMutableBorrow {
        span: Span,
        declare_span: Option<Span>,
        file_id: usize,
    },
    #[error("this method requires a mutable 'self'")]
    NotMutableSelf {
        span: Span,
        path_span: Span,
        file_id: usize,
    },
}