deny empty tuplets

This commit is contained in:
brevalferrari 2025-06-07 12:58:36 +02:00
parent 7bf1f0c6b1
commit bbccf46d47

View file

@ -170,6 +170,9 @@ pub struct Tuplet(pub TokenVec);
impl Token for Tuplet {
fn apply(&self, mut context: Context) -> Result<Context, CompilerError> {
debug!("⚡ {}", type_name::<Self>());
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 {