diff --git a/src/compiler.rs b/src/compiler.rs index 670fd84..5b4c739 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -170,6 +170,9 @@ pub struct Tuplet(pub TokenVec); impl Token for Tuplet { fn apply(&self, mut context: Context) -> Result { debug!("⚡ {}", type_name::()); + if self.0.as_ref().is_empty() { + return Err(CompilerError::Nilplet); + } let mut old_result = context.result.clone(); context.result.clear(); let mut new_context = self @@ -294,10 +297,14 @@ pub struct SlopeNotFoundError(String); pub enum CompilerError { #[error("expression evaluation: {0:?}")] FastEval(#[from] fasteval::Error), - #[error("{0}")] + #[error(transparent)] VariableNotFound(#[from] VariableNotFoundError), - #[error("{0}")] + #[error(transparent)] SlopeNotFound(#[from] SlopeNotFoundError), + #[error( + "You successfully made a nilplet / noplet (and I don't know what to do with it).\nTo resume compilation, remove any occurrence of \"[]\" in your sheet music." + )] + Nilplet, } impl Context {