From 0d933d865a36fb864b2c197a98d7b522db18c51f Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Wed, 24 Feb 2021 13:53:11 +0800 Subject: [PATCH] Do not test for built-in's when operands are not built-in. --- src/fn_call.rs | 20 ++++++++++++++------ src/token.rs | 8 ++++---- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/fn_call.rs b/src/fn_call.rs index fa066981..d960bc44 100644 --- a/src/fn_call.rs +++ b/src/fn_call.rs @@ -289,18 +289,26 @@ impl Engine { } // See if it is built in. - if args.len() == 2 { + if args.len() == 2 && !args[0].is_variant() && !args[1].is_variant() { match run_builtin_binary_op(fn_name, args[0], args[1])? { Some(v) => return Ok((v, false)), None => (), } - if is_ref && fn_name.ends_with('=') { - let (first, second) = args.split_first_mut().unwrap(); + // Op-assignment? + if is_ref { + match fn_name { + _ if fn_name.len() <= 1 => (), + "==" | "!=" | ">=" | "<=" => (), + _ if fn_name.ends_with('=') => { + let (first, second) = args.split_first_mut().unwrap(); - match run_builtin_op_assignment(fn_name, first, second[0])? { - Some(_) => return Ok((Dynamic::UNIT, false)), - None => (), + match run_builtin_op_assignment(fn_name, first, second[0])? { + Some(_) => return Ok((Dynamic::UNIT, false)), + None => (), + } + } + _ => (), } } } diff --git a/src/token.rs b/src/token.rs index fcbcadf6..7221027c 100644 --- a/src/token.rs +++ b/src/token.rs @@ -1659,25 +1659,25 @@ pub fn is_valid_identifier(name: impl Iterator) -> bool { #[cfg(feature = "unicode-xid-ident")] #[inline(always)] -fn is_id_first_alphabetic(x: char) -> bool { +pub fn is_id_first_alphabetic(x: char) -> bool { unicode_xid::UnicodeXID::is_xid_start(x) } #[cfg(feature = "unicode-xid-ident")] #[inline(always)] -fn is_id_continue(x: char) -> bool { +pub fn is_id_continue(x: char) -> bool { unicode_xid::UnicodeXID::is_xid_continue(x) } #[cfg(not(feature = "unicode-xid-ident"))] #[inline(always)] -fn is_id_first_alphabetic(x: char) -> bool { +pub fn is_id_first_alphabetic(x: char) -> bool { x.is_ascii_alphabetic() } #[cfg(not(feature = "unicode-xid-ident"))] #[inline(always)] -fn is_id_continue(x: char) -> bool { +pub fn is_id_continue(x: char) -> bool { x.is_ascii_alphanumeric() || x == '_' }