From bbccf46d47b95751809478b61796a9c05bdfd762 Mon Sep 17 00:00:00 2001 From: brevalferrari Date: Sat, 7 Jun 2025 12:58:36 +0200 Subject: [PATCH] deny empty tuplets --- src/compiler.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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 {