🚀 Validação de Atribuição para Vetores e Matrizes na Declaração#369
Open
maikvinicius wants to merge 3 commits intodgadelha:mainfrom
Open
🚀 Validação de Atribuição para Vetores e Matrizes na Declaração#369maikvinicius wants to merge 3 commits intodgadelha:mainfrom
maikvinicius wants to merge 3 commits intodgadelha:mainfrom
Conversation
dgadelha
requested changes
Apr 13, 2025
Owner
dgadelha
left a comment
There was a problem hiding this comment.
Obrigado pela contribuição e desculpa pela demora na revisão :)
Deixei uns comentários que são importantes de serem resolvidos para que o PR possa ser mergeado.
There was a problem hiding this comment.
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
packages/runtime/src/PortugolJs.ts:1029
- Consider trimming each element in items_array (e.g., using items_array.map(item => item.trim())) to handle any unexpected whitespace in the assigned values.
const items_array = match ? match[1].split(",") : [];
packages/runtime/src/PortugolJs.ts
Outdated
Comment on lines
+929
to
+930
| const linhas = matrizStr?.split("},{"); | ||
| const tamanho_matriz = linhas?.map(linha => linha.split(",").length); |
There was a problem hiding this comment.
Consider trimming whitespace for each entry after splitting the matrix string (e.g., using linhas.map(l => l.trim())) to ensure robust parsing regardless of extra spaces.
Suggested change
| const linhas = matrizStr?.split("},{"); | |
| const tamanho_matriz = linhas?.map(linha => linha.split(",").length); | |
| const linhas = matrizStr?.split("},{").map(l => l.trim()); |
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.
📌 Descrição
Este PR adiciona validações para garantir que a atribuição de vetores e matrizes respeite os tamanhos declarados, evitando erros de execução e melhorando a confiabilidade do código.
🔍 Alterações Principais
🟢 Matrizes
🟢 Vetores
✅ Benefícios
✔️ Evita atribuições incorretas que poderiam causar comportamentos inesperados.
✔️ Garante maior robustez e previsibilidade no uso de vetores e matrizes.
✔️ Melhora a clareza das mensagens de erro para o usuário.
🧪 Testes & Considerações
captureExceptionpara facilitar a depuração.📌 Pronto para revisão! 🚀