Feat(analyser): verificar chamadas de função (aridade, tipos e callable)#122
Merged
Merged
Conversation
dc53aa4 to
f506898
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat(analyser): verificar chamadas de função (aridade, tipos e callable)
Resumo
Implementa verificações semânticas para chamadas de função e toda a infraestrutura relacionada solicitada na issue: registro de assinaturas de funções, validação de chamadas (existência, se é uma função, aridade correta e compatibilidade dos tipos dos argumentos), além da adição de novos tipos de erro e testes.
O que foi alterado
Analisador semântico
Percorre a AST (
Program → Decl → Stmt → Expr)Registra funções com os tipos de seus parâmetros
Implementa verificações para
Expr::Call:Propaga corretamente o tipo de retorno das chamadas
Tabela de símbolos
params: Option<Vec<QualifierType>>emSymbolpara armazenar os tipos dos parâmetros de funçõesErros semânticos
ArityMismatcheCallNonFunctionemSemanticErrorKindTestes
Adicionados testes para:
Também foram atualizados helpers e construções de testes para incluir o novo campo
paramsquando necessário.Motivação
Essas alterações resolvem a issue ao garantir a correção das chamadas de função durante a análise semântica e melhorar os diagnósticos para erros comuns relacionados a chamadas.
Testes executados
Adicionados testes unitários e executada toda a suíte:
cargo test→ todos os testes passaram (169 passed)Formatação verificada com:
cargo fmt --checkMigração / Observações para revisores
Symbolagora contémparams: Option<Vec<QualifierType>>Qualquer construção direta de
Symboldeve incluirparamsNovos erros semânticos podem ser emitidos:
CallNonFunctionArityMismatchFerramentas que fazem correspondência em
SemanticErrorKindpodem precisar de atualizaçãoPendências / Próximos passos
Expressão de índice:
Expr::Index(TODO)Expressão ternária:
Expr::Ternary(TODO)Checklist
cargo test/cargo fmt --check