Fix CFG builder crash when preprocessor directives span across elsif boundaries#3822
Draft
Fix CFG builder crash when preprocessor directives span across elsif boundaries#3822
Conversation
…sif boundaries When #Если/#КонецЕсли preprocessor directives wrap ИначеЕсли branches at the same level as the if statement, the CFG builder's block stack becomes unbalanced because the preprocessor enter/leave block pairs span across different codeBlock scopes. Fix: detect when a statement-level preproc_if does not have a matching preproc_endif in the same codeBlock, and skip CFG graph manipulation for those unbalanced preprocessor blocks. Co-authored-by: nixel2007 <1132840+nixel2007@users.noreply.github.com>
Co-authored-by: nixel2007 <1132840+nixel2007@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix diagnostic computation error in AllFunctionPathMustHaveReturn
Fix CFG builder crash when preprocessor directives span across elsif boundaries
Feb 17, 2026
Member
|
@copilot из фикса не понятно, работает ли теперь функциональность поиска возвратав ветках. Напиши тесты на такие сложные if-выражения, где диагностика корректно находит ветки с пропушенными возвратами как внутри так и снаружи блока с инструкцией препроцессору |
…rocessor directives Tests verify the diagnostic correctly: - Finds missing returns outside preprocessor blocks - Finds missing returns in branches not wrapped by preprocessor - Produces no false positives when all branches have returns - Handles multiple consecutive preprocessor blocks wrapping elsifs - Handles the original bug pattern from the issue (return+raise coverage) Co-authored-by: nixel2007 <1132840+nixel2007@users.noreply.github.com>
Contributor
Author
Added 5 test methods in commit eafb162 that verify the diagnostic correctly finds missing returns in complex if-expressions with cross-boundary preprocessor directives:
|
Contributor
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.
AllFunctionPathMustHaveReturncrashes when preprocessor#Если/#КонецЕслиwrapsИначеЕслиbranches in anIfstatement#Еслиin one elsif branch's codeBlock does not have a matching#КонецЕслиin the same codeBlock (because it spans across elsif boundaries), the CFG builder's block stack becomes unbalanced, leading toNoSuchElementExceptionorFlowGraphLinkExceptionCfgBuildingParseTreeVisitor.visitPreproc_if()to check whether matching#КонецЕслиexists in the same codeBlock before creating graph nodeshasMatchingEndIfInSameCodeBlock()helper method to detect unbalanced preprocessor blocksOriginal prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.