diff --git a/cl-interpret/src/lib.rs b/cl-interpret/src/lib.rs index 7d2fd6d..b5e9b41 100644 --- a/cl-interpret/src/lib.rs +++ b/cl-interpret/src/lib.rs @@ -282,7 +282,9 @@ pub mod temp_type_impl { ')'.fmt(f) } ConValue::Function(func) => { - write!(f, "fn {}", func.name()) + use cl_ast::format::*; + use std::fmt::Write; + write!(f.pretty(), "{}", func.decl()) } ConValue::BuiltIn(func) => { write!(f, "{}", func.description()) @@ -311,6 +313,9 @@ pub mod function { pub fn new(decl: &FnDecl) -> Self { Self { decl: decl.clone().into() } } + pub fn decl(&self) -> &FnDecl { + &self.decl + } } impl Callable for Function { @@ -592,7 +597,11 @@ pub mod error { write!(f, "{value} is not callable.") } Error::ArgNumber { want, got } => { - write!(f, "Expected {want} arguments, got {got}") + write!( + f, + "Expected {want} argument{}, got {got}", + if *want == 1 { "" } else { "s" } + ) } Error::NullPointer => { write!(f, "Attempted to dereference a null pointer?")