diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b4bbbc5..7608ccc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ Breaking changes * Shebangs at the very beginning of script files are skipped when loading them. * [`smartstring`](https://crates.io/crates/smartstring) is used for identifiers by default. Currently, a PR branch is pulled because it breaks on `no-std` builds. The official crate will be used once `smartstring` is fixed to support `no-std`. * `Map` is now an alias to `BTreeMap` instead of `HashMap` because most object maps hold few properties. +* `EvalAltResult::FnWrongDefinition` is renamed `WrongFnDefinition` for consistency. New features ------------ diff --git a/src/fn_call.rs b/src/fn_call.rs index e7cef8ca..f323632b 100644 --- a/src/fn_call.rs +++ b/src/fn_call.rs @@ -866,7 +866,7 @@ impl Engine { // If new functions are defined within the eval string, it is an error if ast.lib().count().0 != 0 { - return Err(ParseErrorType::FnWrongDefinition.into()); + return Err(ParseErrorType::WrongFnDefinition.into()); } // Evaluate the AST diff --git a/src/parse_error.rs b/src/parse_error.rs index b31608b6..a0a62e00 100644 --- a/src/parse_error.rs +++ b/src/parse_error.rs @@ -132,7 +132,7 @@ pub enum ParseErrorType { /// Defining a function `fn` in an appropriate place (e.g. inside another function). /// /// Never appears under the `no_function` feature. - FnWrongDefinition, + WrongFnDefinition, /// Defining a function with a name that conflicts with an existing function. /// Wrapped values are the function name and number of parameters. /// @@ -199,7 +199,7 @@ impl ParseErrorType { Self::VariableExpected => "Expecting name of a variable", Self::Reserved(_) => "Invalid use of reserved keyword", Self::ExprExpected(_) => "Expecting an expression", - Self::FnWrongDefinition => "Function definitions must be at global level and cannot be inside a block or another function", + Self::WrongFnDefinition => "Function definitions must be at global level and cannot be inside a block or another function", Self::FnDuplicatedDefinition(_, _) => "Function already exists", Self::FnMissingName => "Expecting function name in function declaration", Self::FnMissingParams(_) => "Expecting parameters in function declaration", diff --git a/src/parser.rs b/src/parser.rs index 083bd996..49c1d57d 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -2481,7 +2481,7 @@ fn parse_stmt( // fn ... #[cfg(not(feature = "no_function"))] - Token::Fn if !settings.is_global => Err(PERR::FnWrongDefinition.into_err(settings.pos)), + Token::Fn if !settings.is_global => Err(PERR::WrongFnDefinition.into_err(settings.pos)), #[cfg(not(feature = "no_function"))] Token::Fn | Token::Private => { diff --git a/src/token.rs b/src/token.rs index ecd4d661..c5498416 100644 --- a/src/token.rs +++ b/src/token.rs @@ -875,7 +875,7 @@ pub fn parse_string_literal( match next_char { // \r - ignore if followed by \n - '\r' if stream.peek_next().unwrap_or('\0') == '\n' => {} + '\r' if stream.peek_next().map(|ch| ch == '\n').unwrap_or(false) => {} // \... '\\' if escape.is_empty() && !verbatim => { escape.push('\\');