From eb4636f219a05bc590f9eed844363f47a252d37f Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Sat, 21 Nov 2020 15:15:14 +0800 Subject: [PATCH] Fix LexError::ImproperSymbol. --- src/serde_impl/de.rs | 2 +- tests/syntax.rs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/serde_impl/de.rs b/src/serde_impl/de.rs index b4e6786c..6d7fcfed 100644 --- a/src/serde_impl/de.rs +++ b/src/serde_impl/de.rs @@ -120,7 +120,7 @@ pub fn from_dynamic<'de, T: Deserialize<'de>>( impl Error for Box { fn custom(err: T) -> Self { EvalAltResult::ErrorParsing( - ParseErrorType::BadInput(LexError::ImproperSymbol(err.to_string())), + ParseErrorType::BadInput(LexError::ImproperSymbol("".to_string(), err.to_string())), Position::NONE, ) .into() diff --git a/tests/syntax.rs b/tests/syntax.rs index 819931e6..526ebf92 100644 --- a/tests/syntax.rs +++ b/tests/syntax.rs @@ -79,6 +79,7 @@ fn test_custom_syntax() -> Result<(), Box> { .expect_err("should error") .0, ParseErrorType::BadInput(LexError::ImproperSymbol( + "!".to_string(), "Improper symbol for custom syntax at position #1: '!'".to_string() )) ); @@ -100,6 +101,7 @@ fn test_custom_syntax_raw() -> Result<(), Box> { s => Err(ParseError( Box::new(ParseErrorType::BadInput(LexError::ImproperSymbol( s.to_string(), + "".to_string(), ))), Position::NONE, )), @@ -128,7 +130,7 @@ fn test_custom_syntax_raw() -> Result<(), Box> { assert_eq!(engine.eval::("(hello kitty) + foo")?, 1041); assert_eq!( *engine.compile("hello hey").expect_err("should error").0, - ParseErrorType::BadInput(LexError::ImproperSymbol("hey".to_string())) + ParseErrorType::BadInput(LexError::ImproperSymbol("hey".to_string(), "".to_string())) ); Ok(())