Use .. for (_).
This commit is contained in:
parent
97a8fd3d5b
commit
7686ca619a
@ -366,7 +366,7 @@ impl Parse for ExportedFn {
|
||||
}) => {
|
||||
matches!(flatten_type_groups(elem.as_ref()), syn::Type::Path(ref p) if p.path == str_type_path)
|
||||
}
|
||||
syn::Type::Verbatim(_) => false,
|
||||
syn::Type::Verbatim(..) => false,
|
||||
_ => true,
|
||||
};
|
||||
if !is_ok {
|
||||
@ -381,13 +381,13 @@ impl Parse for ExportedFn {
|
||||
match fn_all.sig.output {
|
||||
syn::ReturnType::Type(.., ref ret_type) => {
|
||||
match flatten_type_groups(ret_type.as_ref()) {
|
||||
syn::Type::Ptr(_) => {
|
||||
syn::Type::Ptr(..) => {
|
||||
return Err(syn::Error::new(
|
||||
fn_all.sig.output.span(),
|
||||
"Rhai functions cannot return pointers",
|
||||
))
|
||||
}
|
||||
syn::Type::Reference(_) => {
|
||||
syn::Type::Reference(..) => {
|
||||
return Err(syn::Error::new(
|
||||
fn_all.sig.output.span(),
|
||||
"Rhai functions cannot return references",
|
||||
@ -544,28 +544,28 @@ impl ExportedFn {
|
||||
|
||||
match params.special {
|
||||
// 2a. Property getters must take only the subject as an argument.
|
||||
FnSpecialAccess::Property(Property::Get(_)) if self.arg_count() != 1 => {
|
||||
FnSpecialAccess::Property(Property::Get(..)) if self.arg_count() != 1 => {
|
||||
return Err(syn::Error::new(
|
||||
self.signature.inputs.span(),
|
||||
"property getter requires exactly 1 parameter",
|
||||
))
|
||||
}
|
||||
// 2b. Property getters must return a value.
|
||||
FnSpecialAccess::Property(Property::Get(_)) if self.return_type().is_none() => {
|
||||
FnSpecialAccess::Property(Property::Get(..)) if self.return_type().is_none() => {
|
||||
return Err(syn::Error::new(
|
||||
self.signature.span(),
|
||||
"property getter must return a value",
|
||||
))
|
||||
}
|
||||
// 3a. Property setters must take the subject and a new value as arguments.
|
||||
FnSpecialAccess::Property(Property::Set(_)) if self.arg_count() != 2 => {
|
||||
FnSpecialAccess::Property(Property::Set(..)) if self.arg_count() != 2 => {
|
||||
return Err(syn::Error::new(
|
||||
self.signature.inputs.span(),
|
||||
"property setter requires exactly 2 parameters",
|
||||
))
|
||||
}
|
||||
// 3b. Non-raw property setters must return nothing.
|
||||
FnSpecialAccess::Property(Property::Set(_))
|
||||
FnSpecialAccess::Property(Property::Set(..))
|
||||
if params.return_raw.is_none() && self.return_type().is_some() =>
|
||||
{
|
||||
return Err(syn::Error::new(
|
||||
@ -734,7 +734,7 @@ impl ExportedFn {
|
||||
.unwrap(),
|
||||
);
|
||||
}
|
||||
syn::FnArg::Receiver(_) => todo!("true self parameters not implemented yet"),
|
||||
syn::FnArg::Receiver(..) => todo!("true self parameters not implemented yet"),
|
||||
}
|
||||
unpack_exprs.push(syn::parse2::<syn::Expr>(quote! { #var }).unwrap());
|
||||
} else {
|
||||
@ -811,7 +811,7 @@ impl ExportedFn {
|
||||
);
|
||||
}
|
||||
}
|
||||
syn::FnArg::Receiver(_) => panic!("internal error: how did this happen!?"),
|
||||
syn::FnArg::Receiver(..) => panic!("internal error: how did this happen!?"),
|
||||
}
|
||||
if !is_ref {
|
||||
unpack_exprs.push(syn::parse2::<syn::Expr>(quote! { #var }).unwrap());
|
||||
|
@ -144,12 +144,14 @@ impl Parse for Module {
|
||||
attrs,
|
||||
ty,
|
||||
..
|
||||
}) if matches!(vis, syn::Visibility::Public(_)) => consts.push(ExportedConst {
|
||||
}) if matches!(vis, syn::Visibility::Public(..)) => {
|
||||
consts.push(ExportedConst {
|
||||
name: ident.to_string(),
|
||||
typ: ty.clone(),
|
||||
expr: expr.as_ref().clone(),
|
||||
cfg_attrs: crate::attrs::collect_cfg_attr(&attrs),
|
||||
}),
|
||||
})
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@ -161,7 +163,7 @@ impl Parse for Module {
|
||||
let mut i = 0;
|
||||
while i < content.len() {
|
||||
match content[i] {
|
||||
syn::Item::Mod(_) => {
|
||||
syn::Item::Mod(..) => {
|
||||
let mut item_mod = match content.remove(i) {
|
||||
syn::Item::Mod(m) => m,
|
||||
_ => unreachable!(),
|
||||
@ -212,7 +214,7 @@ impl Module {
|
||||
pub fn update_scope(&mut self, parent_scope: &ExportScope) {
|
||||
let keep = match (self.params.skip, parent_scope) {
|
||||
(true, ..) => false,
|
||||
(.., ExportScope::PubOnly) => matches!(self.mod_all.vis, syn::Visibility::Public(_)),
|
||||
(.., ExportScope::PubOnly) => matches!(self.mod_all.vis, syn::Visibility::Public(..)),
|
||||
(.., ExportScope::Prefix(s)) => self.mod_all.ident.to_string().starts_with(s),
|
||||
(.., ExportScope::All) => true,
|
||||
};
|
||||
|
@ -99,7 +99,7 @@ pub fn generate_body(
|
||||
let fn_input_types: Vec<_> = function
|
||||
.arg_list()
|
||||
.map(|fn_arg| match fn_arg {
|
||||
syn::FnArg::Receiver(_) => panic!("internal error: receiver fn outside impl!?"),
|
||||
syn::FnArg::Receiver(..) => panic!("internal error: receiver fn outside impl!?"),
|
||||
syn::FnArg::Typed(syn::PatType { ref ty, .. }) => {
|
||||
let arg_type = match flatten_type_groups(ty.as_ref()) {
|
||||
syn::Type::Reference(syn::TypeReference {
|
||||
@ -150,7 +150,7 @@ pub fn generate_body(
|
||||
|
||||
match function.params().special {
|
||||
FnSpecialAccess::None => (),
|
||||
FnSpecialAccess::Index(_) | FnSpecialAccess::Property(_) => {
|
||||
FnSpecialAccess::Index(..) | FnSpecialAccess::Property(..) => {
|
||||
let reg_name = fn_literal.value();
|
||||
if reg_name.starts_with(FN_GET)
|
||||
|| reg_name.starts_with(FN_SET)
|
||||
@ -254,7 +254,7 @@ pub fn check_rename_collisions(fns: &[ExportedFn]) -> Result<(), syn::Error> {
|
||||
.arg_list()
|
||||
.fold(name.to_string(), |mut arg_str, fn_arg| {
|
||||
let type_string: String = match fn_arg {
|
||||
syn::FnArg::Receiver(_) => unimplemented!("receiver rhai_fns not implemented"),
|
||||
syn::FnArg::Receiver(..) => unimplemented!("receiver rhai_fns not implemented"),
|
||||
syn::FnArg::Typed(syn::PatType { ref ty, .. }) => print_type(ty),
|
||||
};
|
||||
arg_str.push('.');
|
||||
|
@ -226,7 +226,7 @@ impl Engine {
|
||||
|
||||
match Token::lookup_from_syntax(keyword.as_ref()) {
|
||||
// Standard identifiers, reserved keywords and custom keywords are OK
|
||||
None | Some(Token::Reserved(_)) | Some(Token::Custom(_)) => (),
|
||||
None | Some(Token::Reserved(..)) | Some(Token::Custom(..)) => (),
|
||||
// Active standard keywords cannot be made custom
|
||||
// Disabled keywords are OK
|
||||
Some(token) if token.is_standard_keyword() => {
|
||||
|
@ -449,7 +449,7 @@ impl AST {
|
||||
/// foo("!")
|
||||
/// "#)?;
|
||||
///
|
||||
/// // Merge 'ast2', picking only 'error()' but not 'foo(_)', into 'ast1'
|
||||
/// // Merge 'ast2', picking only 'error()' but not 'foo(..)', into 'ast1'
|
||||
/// let ast = ast1.merge_filtered(&ast2, |_, _, script, name, params|
|
||||
/// script && name == "error" && params == 0);
|
||||
///
|
||||
@ -551,7 +551,7 @@ impl AST {
|
||||
/// foo("!")
|
||||
/// "#)?;
|
||||
///
|
||||
/// // Combine 'ast2', picking only 'error()' but not 'foo(_)', into 'ast1'
|
||||
/// // Combine 'ast2', picking only 'error()' but not 'foo(..)', into 'ast1'
|
||||
/// ast1.combine_filtered(ast2, |_, _, script, name, params|
|
||||
/// script && name == "error" && params == 0);
|
||||
///
|
||||
@ -613,7 +613,7 @@ impl AST {
|
||||
/// fn bar() { print("hello"); }
|
||||
/// "#)?;
|
||||
///
|
||||
/// // Remove all functions except 'foo(_)'
|
||||
/// // Remove all functions except 'foo(..)'
|
||||
/// ast.retain_functions(|_, _, name, params| name == "foo" && params == 1);
|
||||
/// # }
|
||||
/// # Ok(())
|
||||
|
@ -450,7 +450,7 @@ impl fmt::Debug for Expr {
|
||||
Self::FloatConstant(value, ..) => write!(f, "{:?}", value),
|
||||
Self::CharConstant(value, ..) => write!(f, "{:?}", value),
|
||||
Self::StringConstant(value, ..) => write!(f, "{:?}", value),
|
||||
Self::Unit(_) => f.write_str("()"),
|
||||
Self::Unit(..) => f.write_str("()"),
|
||||
|
||||
Self::InterpolatedString(x, ..) => {
|
||||
f.write_str("InterpolatedString")?;
|
||||
@ -535,7 +535,7 @@ impl Expr {
|
||||
Self::CharConstant(x, ..) => (*x).into(),
|
||||
Self::StringConstant(x, ..) => x.clone().into(),
|
||||
Self::BoolConstant(x, ..) => (*x).into(),
|
||||
Self::Unit(_) => Dynamic::UNIT,
|
||||
Self::Unit(..) => Dynamic::UNIT,
|
||||
|
||||
#[cfg(not(feature = "no_index"))]
|
||||
Self::Array(x, ..) if self.is_constant() => {
|
||||
@ -772,7 +772,7 @@ impl Expr {
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub const fn is_unit(&self) -> bool {
|
||||
matches!(self, Self::Unit(_))
|
||||
matches!(self, Self::Unit(..))
|
||||
}
|
||||
/// Is the expression a constant?
|
||||
#[inline]
|
||||
@ -787,7 +787,7 @@ impl Expr {
|
||||
| Self::IntegerConstant(..)
|
||||
| Self::CharConstant(..)
|
||||
| Self::StringConstant(..)
|
||||
| Self::Unit(_)
|
||||
| Self::Unit(..)
|
||||
| Self::Stack(..) => true,
|
||||
|
||||
Self::InterpolatedString(x, ..) | Self::Array(x, ..) => x.iter().all(Self::is_constant),
|
||||
@ -816,13 +816,13 @@ impl Expr {
|
||||
| Self::CharConstant(..)
|
||||
| Self::And(..)
|
||||
| Self::Or(..)
|
||||
| Self::Unit(_) => false,
|
||||
| Self::Unit(..) => false,
|
||||
|
||||
Self::IntegerConstant(..)
|
||||
| Self::StringConstant(..)
|
||||
| Self::InterpolatedString(..)
|
||||
| Self::FnCall(..)
|
||||
| Self::Stmt(_)
|
||||
| Self::Stmt(..)
|
||||
| Self::Dot(..)
|
||||
| Self::Index(..)
|
||||
| Self::Array(..)
|
||||
|
@ -404,7 +404,7 @@ impl Stmt {
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub const fn is_noop(&self) -> bool {
|
||||
matches!(self, Self::Noop(_))
|
||||
matches!(self, Self::Noop(..))
|
||||
}
|
||||
/// Get the [position][Position] of this statement.
|
||||
#[must_use]
|
||||
@ -432,7 +432,7 @@ impl Stmt {
|
||||
Self::Export(.., pos) => *pos,
|
||||
|
||||
#[cfg(not(feature = "no_closure"))]
|
||||
Self::Share(_) => Position::NONE,
|
||||
Self::Share(..) => Position::NONE,
|
||||
}
|
||||
}
|
||||
/// Override the [position][Position] of this statement.
|
||||
@ -462,7 +462,7 @@ impl Stmt {
|
||||
Self::Export(.., pos) => *pos = new_pos,
|
||||
|
||||
#[cfg(not(feature = "no_closure"))]
|
||||
Self::Share(_) => (),
|
||||
Self::Share(..) => (),
|
||||
}
|
||||
|
||||
self
|
||||
@ -474,10 +474,10 @@ impl Stmt {
|
||||
Self::If(..)
|
||||
| Self::Switch(..)
|
||||
| Self::Block(..)
|
||||
| Self::Expr(_)
|
||||
| Self::Expr(..)
|
||||
| Self::FnCall(..) => true,
|
||||
|
||||
Self::Noop(_) | Self::While(..) | Self::Do(..) | Self::For(..) | Self::TryCatch(..) => {
|
||||
Self::Noop(..) | Self::While(..) | Self::Do(..) | Self::For(..) | Self::TryCatch(..) => {
|
||||
false
|
||||
}
|
||||
|
||||
@ -487,7 +487,7 @@ impl Stmt {
|
||||
Self::Import(..) | Self::Export(..) => false,
|
||||
|
||||
#[cfg(not(feature = "no_closure"))]
|
||||
Self::Share(_) => false,
|
||||
Self::Share(..) => false,
|
||||
}
|
||||
}
|
||||
/// Is this statement self-terminated (i.e. no need for a semicolon terminator)?
|
||||
@ -502,13 +502,13 @@ impl Stmt {
|
||||
| Self::TryCatch(..) => true,
|
||||
|
||||
// A No-op requires a semicolon in order to know it is an empty statement!
|
||||
Self::Noop(_) => false,
|
||||
Self::Noop(..) => false,
|
||||
|
||||
Self::Expr(Expr::Custom(x, ..)) if x.is_self_terminated() => true,
|
||||
|
||||
Self::Var(..)
|
||||
| Self::Assignment(..)
|
||||
| Self::Expr(_)
|
||||
| Self::Expr(..)
|
||||
| Self::FnCall(..)
|
||||
| Self::Do(..)
|
||||
| Self::BreakLoop(..)
|
||||
@ -518,7 +518,7 @@ impl Stmt {
|
||||
Self::Import(..) | Self::Export(..) => false,
|
||||
|
||||
#[cfg(not(feature = "no_closure"))]
|
||||
Self::Share(_) => false,
|
||||
Self::Share(..) => false,
|
||||
}
|
||||
}
|
||||
/// Is this statement _pure_?
|
||||
@ -527,7 +527,7 @@ impl Stmt {
|
||||
#[must_use]
|
||||
pub fn is_pure(&self) -> bool {
|
||||
match self {
|
||||
Self::Noop(_) => true,
|
||||
Self::Noop(..) => true,
|
||||
Self::Expr(expr) => expr.is_pure(),
|
||||
Self::If(condition, x, ..) => {
|
||||
condition.is_pure()
|
||||
@ -575,7 +575,7 @@ impl Stmt {
|
||||
Self::Export(..) => false,
|
||||
|
||||
#[cfg(not(feature = "no_closure"))]
|
||||
Self::Share(_) => false,
|
||||
Self::Share(..) => false,
|
||||
}
|
||||
}
|
||||
/// Does this statement's behavior depend on its containing block?
|
||||
|
@ -724,7 +724,9 @@ impl Engine {
|
||||
|
||||
match expr {
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
Expr::FnCall(x, ..) if _parent_chain_type == ChainType::Dotting && !x.is_qualified() => {
|
||||
Expr::FnCall(x, ..)
|
||||
if _parent_chain_type == ChainType::Dotting && !x.is_qualified() =>
|
||||
{
|
||||
let crate::ast::FnCallExpr {
|
||||
args, constants, ..
|
||||
} = x.as_ref();
|
||||
|
@ -465,16 +465,16 @@ impl Engine {
|
||||
|
||||
// Skip transitive nodes
|
||||
match node {
|
||||
ASTNode::Expr(Expr::Stmt(_)) | ASTNode::Stmt(Stmt::Expr(_)) => return Ok(None),
|
||||
ASTNode::Expr(Expr::Stmt(..)) | ASTNode::Stmt(Stmt::Expr(..)) => return Ok(None),
|
||||
_ => (),
|
||||
}
|
||||
|
||||
let stop = match global.debugger.status {
|
||||
DebuggerStatus::Next(false, false) => false,
|
||||
DebuggerStatus::Next(true, false) => matches!(node, ASTNode::Stmt(_)),
|
||||
DebuggerStatus::Next(false, true) => matches!(node, ASTNode::Expr(_)),
|
||||
DebuggerStatus::Next(true, false) => matches!(node, ASTNode::Stmt(..)),
|
||||
DebuggerStatus::Next(false, true) => matches!(node, ASTNode::Expr(..)),
|
||||
DebuggerStatus::Next(true, true) => true,
|
||||
DebuggerStatus::FunctionExit(_) => false,
|
||||
DebuggerStatus::FunctionExit(..) => false,
|
||||
};
|
||||
|
||||
let event = if stop {
|
||||
|
@ -324,7 +324,7 @@ impl Engine {
|
||||
Expr::StringConstant(x, ..) => Ok(x.clone().into()),
|
||||
Expr::CharConstant(x, ..) => Ok((*x).into()),
|
||||
Expr::BoolConstant(x, ..) => Ok((*x).into()),
|
||||
Expr::Unit(_) => Ok(Dynamic::UNIT),
|
||||
Expr::Unit(..) => Ok(Dynamic::UNIT),
|
||||
|
||||
// `... ${...} ...`
|
||||
Expr::InterpolatedString(x, pos) => {
|
||||
|
@ -323,7 +323,7 @@ impl Engine {
|
||||
|
||||
let result = match stmt {
|
||||
// No-op
|
||||
Stmt::Noop(_) => Ok(Dynamic::UNIT),
|
||||
Stmt::Noop(..) => Ok(Dynamic::UNIT),
|
||||
|
||||
// Expression as statement
|
||||
Stmt::Expr(expr) => self
|
||||
@ -483,7 +483,7 @@ impl Engine {
|
||||
}
|
||||
|
||||
// Loop
|
||||
Stmt::While(Expr::Unit(_), body, ..) => loop {
|
||||
Stmt::While(Expr::Unit(..), body, ..) => loop {
|
||||
if !body.is_empty() {
|
||||
match self
|
||||
.eval_stmt_block(scope, global, state, lib, this_ptr, body, true, level)
|
||||
|
@ -144,10 +144,10 @@ impl<'a> Target<'a> {
|
||||
#[must_use]
|
||||
pub const fn is_ref(&self) -> bool {
|
||||
match self {
|
||||
Self::RefMut(_) => true,
|
||||
Self::RefMut(..) => true,
|
||||
#[cfg(not(feature = "no_closure"))]
|
||||
Self::SharedValue { .. } => true,
|
||||
Self::TempValue(_) => false,
|
||||
Self::TempValue(..) => false,
|
||||
#[cfg(not(feature = "no_index"))]
|
||||
Self::Bit { .. }
|
||||
| Self::BitField { .. }
|
||||
@ -160,10 +160,10 @@ impl<'a> Target<'a> {
|
||||
#[must_use]
|
||||
pub const fn is_temp_value(&self) -> bool {
|
||||
match self {
|
||||
Self::RefMut(_) => false,
|
||||
Self::RefMut(..) => false,
|
||||
#[cfg(not(feature = "no_closure"))]
|
||||
Self::SharedValue { .. } => false,
|
||||
Self::TempValue(_) => true,
|
||||
Self::TempValue(..) => true,
|
||||
#[cfg(not(feature = "no_index"))]
|
||||
Self::Bit { .. }
|
||||
| Self::BitField { .. }
|
||||
@ -275,7 +275,7 @@ impl<'a> Target<'a> {
|
||||
#[inline]
|
||||
pub fn propagate_changed_value(&mut self) -> RhaiResultOf<()> {
|
||||
match self {
|
||||
Self::RefMut(_) | Self::TempValue(_) => (),
|
||||
Self::RefMut(..) | Self::TempValue(..) => (),
|
||||
#[cfg(not(feature = "no_closure"))]
|
||||
Self::SharedValue { .. } => (),
|
||||
#[cfg(not(feature = "no_index"))]
|
||||
|
@ -972,7 +972,7 @@ impl Engine {
|
||||
// Do not match function exit for arguments
|
||||
#[cfg(feature = "debugging")]
|
||||
let reset_debugger = global.debugger.clear_status_if(|status| {
|
||||
matches!(status, crate::eval::DebuggerStatus::FunctionExit(_))
|
||||
matches!(status, crate::eval::DebuggerStatus::FunctionExit(..))
|
||||
});
|
||||
|
||||
let result = self.eval_expr(scope, global, state, lib, this_ptr, arg_expr, level);
|
||||
|
@ -30,10 +30,10 @@ pub enum CallableFunction {
|
||||
impl fmt::Debug for CallableFunction {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::Pure(_) => write!(f, "NativePureFunction"),
|
||||
Self::Method(_) => write!(f, "NativeMethod"),
|
||||
Self::Iterator(_) => write!(f, "NativeIterator"),
|
||||
Self::Plugin(_) => write!(f, "PluginFunction"),
|
||||
Self::Pure(..) => write!(f, "NativePureFunction"),
|
||||
Self::Method(..) => write!(f, "NativeMethod"),
|
||||
Self::Iterator(..) => write!(f, "NativeIterator"),
|
||||
Self::Plugin(..) => write!(f, "PluginFunction"),
|
||||
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
Self::Script(fn_def) => fmt::Debug::fmt(fn_def, f),
|
||||
@ -44,10 +44,10 @@ impl fmt::Debug for CallableFunction {
|
||||
impl fmt::Display for CallableFunction {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::Pure(_) => write!(f, "NativePureFunction"),
|
||||
Self::Method(_) => write!(f, "NativeMethod"),
|
||||
Self::Iterator(_) => write!(f, "NativeIterator"),
|
||||
Self::Plugin(_) => write!(f, "PluginFunction"),
|
||||
Self::Pure(..) => write!(f, "NativePureFunction"),
|
||||
Self::Method(..) => write!(f, "NativeMethod"),
|
||||
Self::Iterator(..) => write!(f, "NativeIterator"),
|
||||
Self::Plugin(..) => write!(f, "PluginFunction"),
|
||||
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
Self::Script(s) => fmt::Display::fmt(s, f),
|
||||
@ -61,13 +61,13 @@ impl CallableFunction {
|
||||
#[must_use]
|
||||
pub fn is_pure(&self) -> bool {
|
||||
match self {
|
||||
Self::Pure(_) => true,
|
||||
Self::Method(_) | Self::Iterator(_) => false,
|
||||
Self::Pure(..) => true,
|
||||
Self::Method(..) | Self::Iterator(..) => false,
|
||||
|
||||
Self::Plugin(p) => !p.is_method_call(),
|
||||
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
Self::Script(_) => false,
|
||||
Self::Script(..) => false,
|
||||
}
|
||||
}
|
||||
/// Is this a native Rust method function?
|
||||
@ -75,13 +75,13 @@ impl CallableFunction {
|
||||
#[must_use]
|
||||
pub fn is_method(&self) -> bool {
|
||||
match self {
|
||||
Self::Method(_) => true,
|
||||
Self::Pure(_) | Self::Iterator(_) => false,
|
||||
Self::Method(..) => true,
|
||||
Self::Pure(..) | Self::Iterator(..) => false,
|
||||
|
||||
Self::Plugin(p) => p.is_method_call(),
|
||||
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
Self::Script(_) => false,
|
||||
Self::Script(..) => false,
|
||||
}
|
||||
}
|
||||
/// Is this an iterator function?
|
||||
@ -89,11 +89,11 @@ impl CallableFunction {
|
||||
#[must_use]
|
||||
pub const fn is_iter(&self) -> bool {
|
||||
match self {
|
||||
Self::Iterator(_) => true,
|
||||
Self::Pure(_) | Self::Method(_) | Self::Plugin(_) => false,
|
||||
Self::Iterator(..) => true,
|
||||
Self::Pure(..) | Self::Method(..) | Self::Plugin(..) => false,
|
||||
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
Self::Script(_) => false,
|
||||
Self::Script(..) => false,
|
||||
}
|
||||
}
|
||||
/// Is this a script-defined function?
|
||||
@ -105,8 +105,8 @@ impl CallableFunction {
|
||||
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
match self {
|
||||
Self::Script(_) => true,
|
||||
Self::Pure(_) | Self::Method(_) | Self::Iterator(_) | Self::Plugin(_) => false,
|
||||
Self::Script(..) => true,
|
||||
Self::Pure(..) | Self::Method(..) | Self::Iterator(..) | Self::Plugin(..) => false,
|
||||
}
|
||||
}
|
||||
/// Is this a plugin function?
|
||||
@ -114,11 +114,11 @@ impl CallableFunction {
|
||||
#[must_use]
|
||||
pub const fn is_plugin_fn(&self) -> bool {
|
||||
match self {
|
||||
Self::Plugin(_) => true,
|
||||
Self::Pure(_) | Self::Method(_) | Self::Iterator(_) => false,
|
||||
Self::Plugin(..) => true,
|
||||
Self::Pure(..) | Self::Method(..) | Self::Iterator(..) => false,
|
||||
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
Self::Script(_) => false,
|
||||
Self::Script(..) => false,
|
||||
}
|
||||
}
|
||||
/// Is this a native Rust function?
|
||||
@ -130,10 +130,10 @@ impl CallableFunction {
|
||||
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
match self {
|
||||
Self::Pure(_) | Self::Method(_) => true,
|
||||
Self::Plugin(_) => true,
|
||||
Self::Iterator(_) => true,
|
||||
Self::Script(_) => false,
|
||||
Self::Pure(..) | Self::Method(..) => true,
|
||||
Self::Plugin(..) => true,
|
||||
Self::Iterator(..) => true,
|
||||
Self::Script(..) => false,
|
||||
}
|
||||
}
|
||||
/// Get the access mode.
|
||||
@ -145,8 +145,8 @@ impl CallableFunction {
|
||||
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
match self {
|
||||
Self::Plugin(_) => FnAccess::Public,
|
||||
Self::Pure(_) | Self::Method(_) | Self::Iterator(_) => FnAccess::Public,
|
||||
Self::Plugin(..) => FnAccess::Public,
|
||||
Self::Pure(..) | Self::Method(..) | Self::Iterator(..) => FnAccess::Public,
|
||||
Self::Script(f) => f.access,
|
||||
}
|
||||
}
|
||||
@ -156,10 +156,10 @@ impl CallableFunction {
|
||||
pub fn get_native_fn(&self) -> Option<&Shared<FnAny>> {
|
||||
match self {
|
||||
Self::Pure(f) | Self::Method(f) => Some(f),
|
||||
Self::Iterator(_) | Self::Plugin(_) => None,
|
||||
Self::Iterator(..) | Self::Plugin(..) => None,
|
||||
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
Self::Script(_) => None,
|
||||
Self::Script(..) => None,
|
||||
}
|
||||
}
|
||||
/// Get a shared reference to a script-defined function definition.
|
||||
@ -170,7 +170,7 @@ impl CallableFunction {
|
||||
#[must_use]
|
||||
pub const fn get_script_fn_def(&self) -> Option<&Shared<crate::ast::ScriptFnDef>> {
|
||||
match self {
|
||||
Self::Pure(_) | Self::Method(_) | Self::Iterator(_) | Self::Plugin(_) => None,
|
||||
Self::Pure(..) | Self::Method(..) | Self::Iterator(..) | Self::Plugin(..) => None,
|
||||
Self::Script(f) => Some(f),
|
||||
}
|
||||
}
|
||||
@ -180,10 +180,10 @@ impl CallableFunction {
|
||||
pub fn get_iter_fn(&self) -> Option<&IteratorFn> {
|
||||
match self {
|
||||
Self::Iterator(f) => Some(f.as_ref()),
|
||||
Self::Pure(_) | Self::Method(_) | Self::Plugin(_) => None,
|
||||
Self::Pure(..) | Self::Method(..) | Self::Plugin(..) => None,
|
||||
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
Self::Script(_) => None,
|
||||
Self::Script(..) => None,
|
||||
}
|
||||
}
|
||||
/// Get a shared reference to a plugin function.
|
||||
@ -192,10 +192,10 @@ impl CallableFunction {
|
||||
pub fn get_plugin_fn(&self) -> Option<&Shared<FnPlugin>> {
|
||||
match self {
|
||||
Self::Plugin(f) => Some(f),
|
||||
Self::Pure(_) | Self::Method(_) | Self::Iterator(_) => None,
|
||||
Self::Pure(..) | Self::Method(..) | Self::Iterator(..) => None,
|
||||
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
Self::Script(_) => None,
|
||||
Self::Script(..) => None,
|
||||
}
|
||||
}
|
||||
/// Create a new [`CallableFunction::Pure`].
|
||||
|
@ -349,7 +349,7 @@ fn optimize_stmt_block(
|
||||
.map_or_else(|| Stmt::Noop(pos), |e| Stmt::Expr(mem::take(e)));
|
||||
}
|
||||
// { ...; stmt; noop } -> done
|
||||
[.., ref second_last_stmt, Stmt::Noop(_)]
|
||||
[.., ref second_last_stmt, Stmt::Noop(..)]
|
||||
if second_last_stmt.returns_value() =>
|
||||
{
|
||||
break
|
||||
@ -636,7 +636,7 @@ fn optimize_stmt(stmt: &mut Stmt, state: &mut OptimizerState, preserve_result: b
|
||||
if let Some(mut condition) = mem::take(&mut block.condition) {
|
||||
optimize_expr(&mut condition, state, false);
|
||||
match condition {
|
||||
Expr::Unit(_) | Expr::BoolConstant(true, ..) => state.set_dirty(),
|
||||
Expr::Unit(..) | Expr::BoolConstant(true, ..) => state.set_dirty(),
|
||||
_ => block.condition = Some(condition),
|
||||
}
|
||||
}
|
||||
@ -665,7 +665,7 @@ fn optimize_stmt(stmt: &mut Stmt, state: &mut OptimizerState, preserve_result: b
|
||||
if let Some(mut condition) = mem::take(&mut block.condition) {
|
||||
optimize_expr(&mut condition, state, false);
|
||||
match condition {
|
||||
Expr::Unit(_) | Expr::BoolConstant(true, ..) => state.set_dirty(),
|
||||
Expr::Unit(..) | Expr::BoolConstant(true, ..) => state.set_dirty(),
|
||||
_ => block.condition = Some(condition),
|
||||
}
|
||||
}
|
||||
@ -941,8 +941,8 @@ fn optimize_expr(expr: &mut Expr, state: &mut OptimizerState, chaining: bool) {
|
||||
while n < x.len() - 1 {
|
||||
match (mem::take(&mut x[n]), mem::take(&mut x[n+1])) {
|
||||
(Expr::StringConstant(mut s1, pos), Expr::StringConstant(s2, ..)) => { s1 += s2; x[n] = Expr::StringConstant(s1, pos); x.remove(n+1); state.set_dirty(); }
|
||||
(expr1, Expr::Unit(_)) => { x[n] = expr1; x.remove(n+1); state.set_dirty(); }
|
||||
(Expr::Unit(_), expr2) => { x[n+1] = expr2; x.remove(n); state.set_dirty(); }
|
||||
(expr1, Expr::Unit(..)) => { x[n] = expr1; x.remove(n+1); state.set_dirty(); }
|
||||
(Expr::Unit(..), expr2) => { x[n+1] = expr2; x.remove(n); state.set_dirty(); }
|
||||
(expr1, Expr::StringConstant(s, ..)) if s.is_empty() => { x[n] = expr1; x.remove(n+1); state.set_dirty(); }
|
||||
(Expr::StringConstant(s, ..), expr2) if s.is_empty()=> { x[n+1] = expr2; x.remove(n); state.set_dirty(); }
|
||||
(expr1, expr2) => { x[n] = expr1; x[n+1] = expr2; n += 1; }
|
||||
|
@ -291,7 +291,7 @@ impl Expr {
|
||||
/// Raise an error if the expression can never yield a boolean value.
|
||||
fn ensure_bool_expr(self) -> ParseResult<Expr> {
|
||||
let type_name = match self {
|
||||
Expr::Unit(_) => "()",
|
||||
Expr::Unit(..) => "()",
|
||||
Expr::DynamicConstant(ref v, ..) if !v.is::<bool>() => v.type_name(),
|
||||
Expr::IntegerConstant(..) => "a number",
|
||||
#[cfg(not(feature = "no_float"))]
|
||||
@ -312,7 +312,7 @@ impl Expr {
|
||||
/// Raise an error if the expression can never yield an iterable value.
|
||||
fn ensure_iterable(self) -> ParseResult<Expr> {
|
||||
let type_name = match self {
|
||||
Expr::Unit(_) => "()",
|
||||
Expr::Unit(..) => "()",
|
||||
Expr::BoolConstant(..) => "a boolean",
|
||||
Expr::IntegerConstant(..) => "a number",
|
||||
#[cfg(not(feature = "no_float"))]
|
||||
@ -661,7 +661,7 @@ fn parse_index_chain(
|
||||
| Expr::And(..)
|
||||
| Expr::Or(..)
|
||||
| Expr::BoolConstant(..)
|
||||
| Expr::Unit(_) => {
|
||||
| Expr::Unit(..) => {
|
||||
return Err(PERR::MalformedIndexExpr(
|
||||
"Only arrays, object maps and strings can be indexed".into(),
|
||||
)
|
||||
@ -694,7 +694,7 @@ fn parse_index_chain(
|
||||
| Expr::And(..)
|
||||
| Expr::Or(..)
|
||||
| Expr::BoolConstant(..)
|
||||
| Expr::Unit(_) => {
|
||||
| Expr::Unit(..) => {
|
||||
return Err(PERR::MalformedIndexExpr(
|
||||
"Only arrays, object maps and strings can be indexed".into(),
|
||||
)
|
||||
@ -720,7 +720,7 @@ fn parse_index_chain(
|
||||
.into_err(x.start_position()))
|
||||
}
|
||||
// lhs[()]
|
||||
x @ Expr::Unit(_) => {
|
||||
x @ Expr::Unit(..) => {
|
||||
return Err(PERR::MalformedIndexExpr(
|
||||
"Array access expects integer index, not ()".into(),
|
||||
)
|
||||
@ -897,7 +897,9 @@ fn parse_map_literal(
|
||||
}
|
||||
(s, pos)
|
||||
}
|
||||
(Token::InterpolatedString(_), pos) => return Err(PERR::PropertyExpected.into_err(pos)),
|
||||
(Token::InterpolatedString(..), pos) => {
|
||||
return Err(PERR::PropertyExpected.into_err(pos))
|
||||
}
|
||||
(Token::Reserved(s), pos) if is_valid_identifier(s.chars()) => {
|
||||
return Err(PERR::Reserved(s.to_string()).into_err(pos));
|
||||
}
|
||||
@ -951,7 +953,7 @@ fn parse_map_literal(
|
||||
eat_token(input, Token::Comma);
|
||||
}
|
||||
(Token::RightBrace, ..) => (),
|
||||
(Token::Identifier(_), pos) => {
|
||||
(Token::Identifier(..), pos) => {
|
||||
return Err(PERR::MissingToken(
|
||||
Token::Comma.into(),
|
||||
"to separate the items of this object map literal".into(),
|
||||
@ -1147,7 +1149,7 @@ fn parse_switch(
|
||||
)
|
||||
.into_err(*pos))
|
||||
}
|
||||
(..) => (),
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
@ -1183,9 +1185,9 @@ fn parse_primary(
|
||||
let root_expr = match token {
|
||||
Token::EOF => return Err(PERR::UnexpectedEOF.into_err(settings.pos)),
|
||||
|
||||
Token::IntegerConstant(_)
|
||||
| Token::CharConstant(_)
|
||||
| Token::StringConstant(_)
|
||||
Token::IntegerConstant(..)
|
||||
| Token::CharConstant(..)
|
||||
| Token::StringConstant(..)
|
||||
| Token::True
|
||||
| Token::False => match input.next().expect(NEVER_ENDS).0 {
|
||||
Token::IntegerConstant(x) => Expr::IntegerConstant(x, settings.pos),
|
||||
@ -1284,7 +1286,7 @@ fn parse_primary(
|
||||
}
|
||||
|
||||
// Interpolated string
|
||||
Token::InterpolatedString(_) => {
|
||||
Token::InterpolatedString(..) => {
|
||||
let mut segments = StaticVec::<Expr>::new();
|
||||
|
||||
match input.next().expect(NEVER_ENDS) {
|
||||
@ -1352,7 +1354,7 @@ fn parse_primary(
|
||||
}
|
||||
|
||||
// Identifier
|
||||
Token::Identifier(_) => {
|
||||
Token::Identifier(..) => {
|
||||
#[cfg(not(feature = "no_module"))]
|
||||
let none = None;
|
||||
#[cfg(feature = "no_module")]
|
||||
@ -1416,7 +1418,7 @@ fn parse_primary(
|
||||
}
|
||||
|
||||
// Reserved keyword or symbol
|
||||
Token::Reserved(_) => {
|
||||
Token::Reserved(..) => {
|
||||
#[cfg(not(feature = "no_module"))]
|
||||
let none = None;
|
||||
#[cfg(feature = "no_module")]
|
||||
@ -1450,7 +1452,7 @@ fn parse_primary(
|
||||
}
|
||||
}
|
||||
|
||||
Token::LexError(_) => match input.next().expect(NEVER_ENDS) {
|
||||
Token::LexError(..) => match input.next().expect(NEVER_ENDS) {
|
||||
(Token::LexError(err), ..) => return Err(err.into_err(settings.pos)),
|
||||
token => unreachable!("Token::LexError expected but gets {:?}", token),
|
||||
},
|
||||
@ -1575,7 +1577,7 @@ fn parse_postfix(
|
||||
(expr, Token::Period) => {
|
||||
// Expression after dot must start with an identifier
|
||||
match input.peek().expect(NEVER_ENDS) {
|
||||
(Token::Identifier(_), ..) => {
|
||||
(Token::Identifier(..), ..) => {
|
||||
#[cfg(not(feature = "no_closure"))]
|
||||
{
|
||||
// Prevents capturing of the object properties as vars: xxx.<var>
|
||||
@ -2792,7 +2794,7 @@ fn parse_block(
|
||||
eat_token(input, Token::SemiColon);
|
||||
}
|
||||
// { ... { stmt } ???
|
||||
(..) if !need_semicolon => (),
|
||||
_ if !need_semicolon => (),
|
||||
// { ... stmt <error>
|
||||
(Token::LexError(err), err_pos) => return Err(err.clone().into_err(*err_pos)),
|
||||
// { ... stmt ???
|
||||
@ -2874,7 +2876,7 @@ fn parse_stmt(
|
||||
|
||||
match input.peek().expect(NEVER_ENDS) {
|
||||
(Token::Fn, ..) | (Token::Private, ..) => break,
|
||||
(Token::Comment(_), ..) => (),
|
||||
(Token::Comment(..), ..) => (),
|
||||
_ => return Err(PERR::WrongDocComment.into_err(comments_pos)),
|
||||
}
|
||||
}
|
||||
@ -3027,7 +3029,7 @@ fn parse_stmt(
|
||||
// `return;` or `throw;`
|
||||
(Token::SemiColon, ..) => Ok(Stmt::Return(return_type, None, token_pos)),
|
||||
// `return` or `throw` with expression
|
||||
(..) => {
|
||||
_ => {
|
||||
let expr = parse_expr(input, state, lib, settings.level_up())?;
|
||||
Ok(Stmt::Return(return_type, Some(expr), token_pos))
|
||||
}
|
||||
@ -3491,7 +3493,7 @@ impl Engine {
|
||||
// stmt ;
|
||||
(Token::SemiColon, ..) if !need_semicolon => (),
|
||||
// { stmt } ???
|
||||
(..) if !need_semicolon => (),
|
||||
_ if !need_semicolon => (),
|
||||
// stmt <error>
|
||||
(Token::LexError(err), pos) => return Err(err.clone().into_err(*pos)),
|
||||
// stmt ???
|
||||
|
@ -603,8 +603,8 @@ impl Token {
|
||||
FloatConstant(f) => f.to_string().into(),
|
||||
#[cfg(feature = "decimal")]
|
||||
DecimalConstant(d) => d.to_string().into(),
|
||||
StringConstant(_) => "string".into(),
|
||||
InterpolatedString(_) => "string".into(),
|
||||
StringConstant(..) => "string".into(),
|
||||
InterpolatedString(..) => "string".into(),
|
||||
CharConstant(c) => c.to_string().into(),
|
||||
Identifier(s) => s.to_string().into(),
|
||||
Reserved(s) => s.to_string().into(),
|
||||
@ -825,7 +825,7 @@ impl Token {
|
||||
use Token::*;
|
||||
|
||||
match self {
|
||||
LexError(_) |
|
||||
LexError(..) |
|
||||
SemiColon | // ; - is unary
|
||||
Colon | // #{ foo: - is unary
|
||||
Comma | // ( ... , -expr ) - is unary
|
||||
@ -970,7 +970,7 @@ impl Token {
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub const fn is_reserved(&self) -> bool {
|
||||
matches!(self, Self::Reserved(_))
|
||||
matches!(self, Self::Reserved(..))
|
||||
}
|
||||
|
||||
/// Convert a token into a function name, if possible.
|
||||
@ -987,7 +987,7 @@ impl Token {
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub const fn is_custom(&self) -> bool {
|
||||
matches!(self, Self::Custom(_))
|
||||
matches!(self, Self::Custom(..))
|
||||
}
|
||||
}
|
||||
|
||||
@ -2197,7 +2197,7 @@ impl<'a> Iterator for TokenIterator<'a> {
|
||||
// a verbatim string or a string with continuation encounters {EOF}.
|
||||
// This is necessary to handle such cases for line-by-line parsing, but for an entire
|
||||
// script it is a syntax error.
|
||||
Some((Token::StringConstant(_), pos)) if self.state.is_within_text_terminated_by.is_some() => {
|
||||
Some((Token::StringConstant(..), pos)) if self.state.is_within_text_terminated_by.is_some() => {
|
||||
self.state.is_within_text_terminated_by = None;
|
||||
return Some((Token::LexError(LERR::UnterminatedString), pos));
|
||||
}
|
||||
|
@ -153,11 +153,11 @@ impl fmt::Display for EvalAltResult {
|
||||
s => f.write_str(s),
|
||||
}?,
|
||||
Self::ErrorIndexingType(s, ..) => write!(f, "Indexer not registered: {}", s)?,
|
||||
Self::ErrorUnboundThis(_) => f.write_str("'this' is not bound")?,
|
||||
Self::ErrorFor(_) => f.write_str("For loop expects a type that is iterable")?,
|
||||
Self::ErrorTooManyOperations(_) => f.write_str("Too many operations")?,
|
||||
Self::ErrorTooManyModules(_) => f.write_str("Too many modules imported")?,
|
||||
Self::ErrorStackOverflow(_) => f.write_str("Stack overflow")?,
|
||||
Self::ErrorUnboundThis(..) => f.write_str("'this' is not bound")?,
|
||||
Self::ErrorFor(..) => f.write_str("For loop expects a type that is iterable")?,
|
||||
Self::ErrorTooManyOperations(..) => f.write_str("Too many operations")?,
|
||||
Self::ErrorTooManyModules(..) => f.write_str("Too many modules imported")?,
|
||||
Self::ErrorStackOverflow(..) => f.write_str("Stack overflow")?,
|
||||
Self::ErrorTerminated(..) => f.write_str("Script terminated")?,
|
||||
|
||||
Self::ErrorRuntime(d, ..) if d.is::<()>() => f.write_str("Runtime error")?,
|
||||
@ -270,13 +270,13 @@ impl EvalAltResult {
|
||||
Self::ErrorFunctionNotFound(..)
|
||||
| Self::ErrorInFunctionCall(..)
|
||||
| Self::ErrorInModule(..)
|
||||
| Self::ErrorUnboundThis(_)
|
||||
| Self::ErrorUnboundThis(..)
|
||||
| Self::ErrorMismatchDataType(..)
|
||||
| Self::ErrorArrayBounds(..)
|
||||
| Self::ErrorStringBounds(..)
|
||||
| Self::ErrorBitFieldBounds(..)
|
||||
| Self::ErrorIndexingType(..)
|
||||
| Self::ErrorFor(_)
|
||||
| Self::ErrorFor(..)
|
||||
| Self::ErrorVariableExists(..)
|
||||
| Self::ErrorVariableNotFound(..)
|
||||
| Self::ErrorModuleNotFound(..)
|
||||
@ -293,9 +293,9 @@ impl EvalAltResult {
|
||||
// Therefore, this error should not be catchable.
|
||||
Self::ErrorCustomSyntax(..) => false,
|
||||
|
||||
Self::ErrorTooManyOperations(_)
|
||||
| Self::ErrorTooManyModules(_)
|
||||
| Self::ErrorStackOverflow(_)
|
||||
Self::ErrorTooManyOperations(..)
|
||||
| Self::ErrorTooManyModules(..)
|
||||
| Self::ErrorStackOverflow(..)
|
||||
| Self::ErrorDataTooLarge(..)
|
||||
| Self::ErrorTerminated(..) => false,
|
||||
|
||||
@ -310,9 +310,9 @@ impl EvalAltResult {
|
||||
Self::ErrorParsing(..) => true,
|
||||
|
||||
Self::ErrorCustomSyntax(..)
|
||||
| Self::ErrorTooManyOperations(_)
|
||||
| Self::ErrorTooManyModules(_)
|
||||
| Self::ErrorStackOverflow(_)
|
||||
| Self::ErrorTooManyOperations(..)
|
||||
| Self::ErrorTooManyModules(..)
|
||||
| Self::ErrorStackOverflow(..)
|
||||
| Self::ErrorDataTooLarge(..) => true,
|
||||
|
||||
Self::ErrorTerminated(..) => true,
|
||||
@ -337,12 +337,12 @@ impl EvalAltResult {
|
||||
|
||||
Self::ErrorSystem(..)
|
||||
| Self::ErrorParsing(..)
|
||||
| Self::ErrorUnboundThis(_)
|
||||
| Self::ErrorFor(_)
|
||||
| Self::ErrorUnboundThis(..)
|
||||
| Self::ErrorFor(..)
|
||||
| Self::ErrorArithmetic(..)
|
||||
| Self::ErrorTooManyOperations(_)
|
||||
| Self::ErrorTooManyModules(_)
|
||||
| Self::ErrorStackOverflow(_)
|
||||
| Self::ErrorTooManyOperations(..)
|
||||
| Self::ErrorTooManyModules(..)
|
||||
| Self::ErrorStackOverflow(..)
|
||||
| Self::ErrorRuntime(..) => (),
|
||||
|
||||
Self::ErrorFunctionNotFound(f, ..) => {
|
||||
|
@ -48,7 +48,7 @@ fn test_closures() -> Result<(), Box<EvalAltResult>> {
|
||||
.compile_expression("let f = |x| {};")
|
||||
.expect_err("should error")
|
||||
.0,
|
||||
ParseErrorType::BadInput(_)
|
||||
ParseErrorType::BadInput(..)
|
||||
));
|
||||
|
||||
assert_eq!(
|
||||
|
@ -74,7 +74,7 @@ fn test_fn_ptr() -> Result<(), Box<EvalAltResult>> {
|
||||
)
|
||||
.expect_err("should error"),
|
||||
EvalAltResult::ErrorInFunctionCall(fn_name, _, err, ..)
|
||||
if fn_name == "foo" && matches!(*err, EvalAltResult::ErrorUnboundThis(_))
|
||||
if fn_name == "foo" && matches!(*err, EvalAltResult::ErrorUnboundThis(..))
|
||||
));
|
||||
|
||||
Ok(())
|
||||
|
@ -249,7 +249,7 @@ fn test_internal_fn_bang() -> Result<(), Box<EvalAltResult>> {
|
||||
)
|
||||
.expect_err("should error")
|
||||
.0,
|
||||
ParseErrorType::MalformedCapture(_)
|
||||
ParseErrorType::MalformedCapture(..)
|
||||
));
|
||||
|
||||
Ok(())
|
||||
|
@ -214,7 +214,7 @@ fn test_module_resolver() -> Result<(), Box<EvalAltResult>> {
|
||||
"#
|
||||
)
|
||||
.expect_err("should error"),
|
||||
EvalAltResult::ErrorTooManyModules(_)
|
||||
EvalAltResult::ErrorTooManyModules(..)
|
||||
));
|
||||
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
|
@ -19,7 +19,7 @@ fn test_max_operations() -> Result<(), Box<EvalAltResult>> {
|
||||
|
||||
assert!(matches!(
|
||||
*engine.run("for x in 0..500 {}").expect_err("should error"),
|
||||
EvalAltResult::ErrorTooManyOperations(_)
|
||||
EvalAltResult::ErrorTooManyOperations(..)
|
||||
));
|
||||
|
||||
engine.set_max_operations(0);
|
||||
@ -44,7 +44,7 @@ fn test_max_operations_literal() -> Result<(), Box<EvalAltResult>> {
|
||||
*engine
|
||||
.run("[1, 2, 3, 4, 5, 6, 7, 8, 9]")
|
||||
.expect_err("should error"),
|
||||
EvalAltResult::ErrorTooManyOperations(_)
|
||||
EvalAltResult::ErrorTooManyOperations(..)
|
||||
));
|
||||
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
@ -55,7 +55,7 @@ fn test_max_operations_literal() -> Result<(), Box<EvalAltResult>> {
|
||||
*engine
|
||||
.run("#{a:1, b:2, c:3, d:4, e:5, f:6, g:7, h:8, i:9}")
|
||||
.expect_err("should error"),
|
||||
EvalAltResult::ErrorTooManyOperations(_)
|
||||
EvalAltResult::ErrorTooManyOperations(..)
|
||||
));
|
||||
|
||||
Ok(())
|
||||
@ -111,7 +111,7 @@ fn test_max_operations_functions() -> Result<(), Box<EvalAltResult>> {
|
||||
"#,
|
||||
)
|
||||
.expect_err("should error"),
|
||||
EvalAltResult::ErrorTooManyOperations(_)
|
||||
EvalAltResult::ErrorTooManyOperations(..)
|
||||
));
|
||||
|
||||
Ok(())
|
||||
@ -138,7 +138,7 @@ fn test_max_operations_eval() -> Result<(), Box<EvalAltResult>> {
|
||||
"#
|
||||
)
|
||||
.expect_err("should error"),
|
||||
EvalAltResult::ErrorInFunctionCall(.., err, _) if matches!(*err, EvalAltResult::ErrorTooManyOperations(_))
|
||||
EvalAltResult::ErrorInFunctionCall(.., err, _) if matches!(*err, EvalAltResult::ErrorTooManyOperations(..))
|
||||
));
|
||||
|
||||
Ok(())
|
||||
|
@ -29,7 +29,7 @@ fn test_stack_overflow_fn_calls() -> Result<(), Box<EvalAltResult>> {
|
||||
max + 1
|
||||
))
|
||||
.expect_err("should error"),
|
||||
EvalAltResult::ErrorStackOverflow(_)
|
||||
EvalAltResult::ErrorStackOverflow(..)
|
||||
));
|
||||
|
||||
Ok(())
|
||||
|
Loading…
Reference in New Issue
Block a user