diff --git a/src/fn_call.rs b/src/fn_call.rs index 21bc570c..5ee9387f 100644 --- a/src/fn_call.rs +++ b/src/fn_call.rs @@ -269,7 +269,7 @@ impl Engine { if let Some(prop) = extract_prop_from_getter(fn_name) { return EvalAltResult::ErrorDotExpr( format!( - "Failed to get property '{}' of '{}' - the property may not exist, or it may be write-only", + "Unknown property '{}' - a getter is not registered for type '{}'", prop, self.map_type_name(args[0].type_name()) ), @@ -283,7 +283,7 @@ impl Engine { if let Some(prop) = extract_prop_from_setter(fn_name) { return EvalAltResult::ErrorDotExpr( format!( - "Failed to set property '{}' of '{}' - the property may not exist, may be read-only, or '{}' is the wrong type", + "No writable property '{}' - a setter is not registered for type '{}' to handle '{}'", prop, self.map_type_name(args[0].type_name()), self.map_type_name(args[1].type_name()), diff --git a/src/result.rs b/src/result.rs index d0ca7e52..39a0b315 100644 --- a/src/result.rs +++ b/src/result.rs @@ -178,8 +178,9 @@ impl fmt::Display for EvalAltResult { Self::ErrorDotExpr(s, _) if !s.is_empty() => write!(f, "{}", s)?, - Self::ErrorIndexingType(_, _) - | Self::ErrorUnboundThis(_) + Self::ErrorIndexingType(s, _) => write!(f, "Indexer not registered for type '{}'", s)?, + + Self::ErrorUnboundThis(_) | Self::ErrorFor(_) | Self::ErrorInExpr(_) | Self::ErrorDotExpr(_, _) diff --git a/src/token.rs b/src/token.rs index de291fbe..93eee9a2 100644 --- a/src/token.rs +++ b/src/token.rs @@ -768,10 +768,13 @@ pub struct TokenizeState { /// /// This trait is volatile and may change. pub trait InputStream { - fn unread(&mut self, ch: char); - /// Get the next character + /// Un-get a character back into the `InputStream`. + /// The next [`get_next`][InputStream::get_next] or [`peek_next`][InputStream::peek_next] + /// will return this character instead. + fn unget(&mut self, ch: char); + /// Get the next character from the `InputStream`. fn get_next(&mut self) -> Option; - /// Peek the next character + /// Peek the next character in the `InputStream`. fn peek_next(&mut self) -> Option; } @@ -1088,12 +1091,12 @@ fn get_next_token_inner( } // _ - cannot follow a decimal point '_' => { - stream.unread(next_char); + stream.unget(next_char); break; } // .. - reserved symbol, not a floating-point number '.' => { - stream.unread(next_char); + stream.unget(next_char); break; } // symbol after period - probably a float @@ -1104,7 +1107,7 @@ fn get_next_token_inner( } // Not a floating-point number _ => { - stream.unread(next_char); + stream.unget(next_char); break; } } @@ -1634,12 +1637,10 @@ pub struct MultiInputsStream<'a> { } impl InputStream for MultiInputsStream<'_> { - /// Buffer a character. #[inline(always)] - fn unread(&mut self, ch: char) { + fn unget(&mut self, ch: char) { self.buf = Some(ch); } - /// Get the next character fn get_next(&mut self) -> Option { if let Some(ch) = self.buf.take() { return Some(ch); @@ -1658,7 +1659,6 @@ impl InputStream for MultiInputsStream<'_> { } } } - /// Peek the next character fn peek_next(&mut self) -> Option { if let Some(ch) = self.buf { return Some(ch);