forked from Orchid/orchid
Most files suffered major changes
- Less ambiguous syntax - Better parser (Chumsky only does tokenization now) - Tidy(|ier) error handling - Facade for simplified embedding - External code grouped in (fairly) self-contained Systems - Dynamic action dispatch - Many STL additions
This commit is contained in:
45
src/error/not_exported.rs
Normal file
45
src/error/not_exported.rs
Normal file
@@ -0,0 +1,45 @@
|
||||
use std::rc::Rc;
|
||||
|
||||
use super::{ErrorPosition, ProjectError};
|
||||
use crate::representations::location::Location;
|
||||
use crate::utils::BoxedIter;
|
||||
use crate::{Interner, VName};
|
||||
|
||||
/// An import refers to a symbol which exists but is not exported.
|
||||
#[derive(Debug)]
|
||||
pub struct NotExported {
|
||||
/// The containing file - files are always exported
|
||||
pub file: VName,
|
||||
/// The path leading to the unexported module
|
||||
pub subpath: VName,
|
||||
/// The offending file
|
||||
pub referrer_file: VName,
|
||||
/// The module containing the offending import
|
||||
pub referrer_subpath: VName,
|
||||
}
|
||||
impl ProjectError for NotExported {
|
||||
fn description(&self) -> &str {
|
||||
"An import refers to a symbol that exists but isn't exported"
|
||||
}
|
||||
fn positions(&self, i: &Interner) -> BoxedIter<ErrorPosition> {
|
||||
Box::new(
|
||||
[
|
||||
ErrorPosition {
|
||||
location: Location::File(Rc::new(i.extern_all(&self.file))),
|
||||
message: Some(format!(
|
||||
"{} isn't exported",
|
||||
i.extern_all(&self.subpath).join("::")
|
||||
)),
|
||||
},
|
||||
ErrorPosition {
|
||||
location: Location::File(Rc::new(i.extern_all(&self.referrer_file))),
|
||||
message: Some(format!(
|
||||
"{} cannot see this symbol",
|
||||
i.extern_all(&self.referrer_subpath).join("::")
|
||||
)),
|
||||
},
|
||||
]
|
||||
.into_iter(),
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user