cl-interpret: Complain, rather than panic, on outlined module

This commit is contained in:
John 2024-07-11 02:48:35 -05:00
parent 58c5a01312
commit d692f6bb80
2 changed files with 6 additions and 5 deletions

View File

@ -60,10 +60,11 @@ impl Interpret for Static {
} }
impl Interpret for Module { impl Interpret for Module {
fn interpret(&self, env: &mut Environment) -> IResult<ConValue> { fn interpret(&self, env: &mut Environment) -> IResult<ConValue> {
let Self { name, kind } = self;
// TODO: Enter this module's namespace // TODO: Enter this module's namespace
match &self.kind { match kind {
ModuleKind::Inline(file) => file.interpret(env), ModuleKind::Inline(file) => file.interpret(env),
ModuleKind::Outline => todo!("Load and parse external files"), ModuleKind::Outline => Err(Error::Outlined(*name)),
} }
} }
} }

View File

@ -580,7 +580,7 @@ pub mod error {
want: usize, want: usize,
got: usize, got: usize,
}, },
NullPointer, Outlined(Sym),
} }
impl std::error::Error for Error {} impl std::error::Error for Error {}
@ -620,8 +620,8 @@ pub mod error {
if *want == 1 { "" } else { "s" } if *want == 1 { "" } else { "s" }
) )
} }
Error::NullPointer => { Error::Outlined(name) => {
write!(f, "Attempted to dereference a null pointer?") write!(f, "Module {name} specified, but not imported.")
} }
} }
} }