From 5d90b3274c7e2dd56cb3d1ebc4716cefe9fde57c Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Mon, 10 Jan 2022 20:08:03 +0800 Subject: [PATCH] Catch unsupported custom syntax. --- src/eval/expr.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/eval/expr.rs b/src/eval/expr.rs index c032823f..2a0e580f 100644 --- a/src/eval/expr.rs +++ b/src/eval/expr.rs @@ -419,7 +419,13 @@ impl Engine { Expr::Custom(custom, _) => { let expressions: StaticVec<_> = custom.inputs.iter().map(Into::into).collect(); let key_token = custom.tokens.first().unwrap(); - let custom_def = self.custom_syntax.get(key_token).unwrap(); + let custom_def = self.custom_syntax.get(key_token).ok_or_else(|| { + let code: Vec<_> = custom.tokens.iter().map(|s| s.as_str()).collect(); + Box::new(ERR::ErrorSystem( + format!("Invalid custom syntax prefix: {}", key_token), + code.join(" ").into(), + )) + })?; let mut context = EvalContext { engine: self, scope,