From d692f6bb80130820e9864757806ef6b4e32b87c1 Mon Sep 17 00:00:00 2001 From: John Date: Thu, 11 Jul 2024 02:48:35 -0500 Subject: [PATCH] cl-interpret: Complain, rather than panic, on outlined module --- compiler/cl-interpret/src/interpret.rs | 5 +++-- compiler/cl-interpret/src/lib.rs | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/compiler/cl-interpret/src/interpret.rs b/compiler/cl-interpret/src/interpret.rs index 543a553..fcfad53 100644 --- a/compiler/cl-interpret/src/interpret.rs +++ b/compiler/cl-interpret/src/interpret.rs @@ -60,10 +60,11 @@ impl Interpret for Static { } impl Interpret for Module { fn interpret(&self, env: &mut Environment) -> IResult { + let Self { name, kind } = self; // TODO: Enter this module's namespace - match &self.kind { + match kind { ModuleKind::Inline(file) => file.interpret(env), - ModuleKind::Outline => todo!("Load and parse external files"), + ModuleKind::Outline => Err(Error::Outlined(*name)), } } } diff --git a/compiler/cl-interpret/src/lib.rs b/compiler/cl-interpret/src/lib.rs index aca2a78..aaa28a0 100644 --- a/compiler/cl-interpret/src/lib.rs +++ b/compiler/cl-interpret/src/lib.rs @@ -580,7 +580,7 @@ pub mod error { want: usize, got: usize, }, - NullPointer, + Outlined(Sym), } impl std::error::Error for Error {} @@ -620,8 +620,8 @@ pub mod error { if *want == 1 { "" } else { "s" } ) } - Error::NullPointer => { - write!(f, "Attempted to dereference a null pointer?") + Error::Outlined(name) => { + write!(f, "Module {name} specified, but not imported.") } } }