Fix error message.

This commit is contained in:
Stephen Chung 2023-03-22 21:38:55 +08:00
parent 9d4972f6d3
commit 2c94f956e5

View File

@ -3612,8 +3612,11 @@ impl Engine {
// Parse type for `this` pointer // Parse type for `this` pointer
#[cfg(not(feature = "no_object"))] #[cfg(not(feature = "no_object"))]
let ((token, pos), this_type) = match token { let ((token, pos), this_type) = {
Token::StringConstant(s) if input.peek().expect(NEVER_ENDS).0 == Token::Period => { let (next_token, next_pos) = input.peek().expect(NEVER_ENDS);
match token {
Token::StringConstant(s) if next_token == &Token::Period => {
eat_token(input, Token::Period); eat_token(input, Token::Period);
let s = match s.as_str() { let s = match s.as_str() {
"int" => state.get_interned_string(std::any::type_name::<crate::INT>()), "int" => state.get_interned_string(std::any::type_name::<crate::INT>()),
@ -3624,9 +3627,13 @@ impl Engine {
(input.next().expect(NEVER_ENDS), Some(s)) (input.next().expect(NEVER_ENDS), Some(s))
} }
Token::StringConstant(..) => { Token::StringConstant(..) => {
return Err(PERR::MissingSymbol(".".to_string()).into_err(pos)) return Err(PERR::MissingToken(
Token::Period.into(),
"after the type name for 'this'".into(),
)
.into_err(*next_pos))
} }
Token::Identifier(s) if input.peek().expect(NEVER_ENDS).0 == Token::Period => { Token::Identifier(s) if next_token == &Token::Period => {
eat_token(input, Token::Period); eat_token(input, Token::Period);
let s = match s.as_str() { let s = match s.as_str() {
"int" => state.get_interned_string(std::any::type_name::<crate::INT>()), "int" => state.get_interned_string(std::any::type_name::<crate::INT>()),
@ -3637,6 +3644,7 @@ impl Engine {
(input.next().expect(NEVER_ENDS), Some(s)) (input.next().expect(NEVER_ENDS), Some(s))
} }
_ => ((token, pos), None), _ => ((token, pos), None),
}
}; };
let name = match token.into_function_name_for_override() { let name = match token.into_function_name_for_override() {