Do not test for built-in's when operands are not built-in.

This commit is contained in:
Stephen Chung 2021-02-24 13:53:11 +08:00
parent c501b34191
commit 0d933d865a
2 changed files with 18 additions and 10 deletions

View File

@ -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 => (),
}
}
_ => (),
}
}
}

View File

@ -1659,25 +1659,25 @@ pub fn is_valid_identifier(name: impl Iterator<Item = char>) -> 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 == '_'
}