Skip to content

Commit 00400ba

Browse files
committed
Corrigido retorno de Erro nas funções de parser de funções comuns e funções de teste
Agora retornamos Error<input> ao invés de Error<name>, para retornar no erro a string original de texto no parser que deu erro
1 parent d28a465 commit 00400ba

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/parser/parser_stmt.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ fn parse_function_definition_statement(input: &str) -> IResult<&str, Statement>
175175
|(_, name, args, _, t, block)| {
176176
if name.starts_with("test") {
177177
// Força falha aqui para evitar aceitar funções test_ no parser geral
178-
Err(nom::Err::Error(Error::new(name, ErrorKind::Tag)))
178+
Err(nom::Err::Error(Error::new(input, ErrorKind::Tag)))
179179
} else {
180180
Ok(Statement::FuncDef(Function {
181181
name: name.to_string(),
@@ -210,13 +210,13 @@ fn parse_test_function_definition_statement(input: &str) -> IResult<&str, Statem
210210
)),
211211
|(_, name, _,opt_ret_type, block)| {
212212
if !name.starts_with("test") {
213-
return Err(nom::Err::Error(Error::new(name, ErrorKind::Tag)));
213+
return Err(nom::Err::Error(Error::new(input, ErrorKind::Tag)));
214214
}
215215

216216
// Se tiver tipo declarado, só aceita Bool
217217
if let Some(ret_type) = opt_ret_type {
218218
if ret_type != Type::TBool {
219-
return Err(nom::Err::Error(Error::new(name, ErrorKind::Tag)));
219+
return Err(nom::Err::Error(Error::new(input, ErrorKind::Tag)));
220220
}
221221
}
222222

0 commit comments

Comments
 (0)