Add constant NO_POS.

This commit is contained in:
Stephen Chung
2020-11-02 12:50:27 +08:00
parent 6f3ce96d9d
commit d7d6f74dfd
29 changed files with 253 additions and 292 deletions

View File

@@ -2,7 +2,7 @@
use crate::dynamic::Dynamic;
use crate::parse_error::ParseErrorType;
use crate::token::Position;
use crate::token::{Position, NO_POS};
use crate::utils::ImmutableString;
use crate::INT;
@@ -252,7 +252,7 @@ impl fmt::Display for EvalAltResult {
impl<T: AsRef<str>> From<T> for EvalAltResult {
#[inline(always)]
fn from(err: T) -> Self {
Self::ErrorRuntime(err.as_ref().to_string().into(), Position::none())
Self::ErrorRuntime(err.as_ref().to_string().into(), NO_POS)
}
}
@@ -261,7 +261,7 @@ impl<T: AsRef<str>> From<T> for Box<EvalAltResult> {
fn from(err: T) -> Self {
Box::new(EvalAltResult::ErrorRuntime(
err.as_ref().to_string().into(),
Position::none(),
NO_POS,
))
}
}
@@ -324,7 +324,7 @@ impl EvalAltResult {
/// Get the `Position` of this error.
pub fn position(&self) -> Position {
match self {
Self::ErrorSystem(_, _) => Position::none(),
Self::ErrorSystem(_, _) => NO_POS,
Self::ErrorParsing(_, pos)
| Self::ErrorFunctionNotFound(_, pos)