You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(types): сохранять локальные значения перед вызовами - #4972
Тип локальной переменной в объявлении терял значения перед вызовами, если в теле не было общих переменных. Добавление неиспользуемой переменной модуля меняло ответ с Строка на Число | Строка.
Значения перед вызовами теперь собираются независимо от наличия общих переменных. Сброс типов самих общих переменных остаётся отдельным шагом. Добавлена регрессия без переменных модуля, прежние проверки границ вызовов и ограничение числа объединений сохранены.
Отладочные, закомментированные и прочие, не имеющие смысла участки кода удалены
Изменения покрыты тестами
Обязательные действия перед коммитом выполнены (gradlew precommit)
Дополнительно
На 7f6854e: весь пакет системы типов — 2226 пройденных тестов, 84 пропущенных, 0 падений; Spotless и precommit прошли. Негативный контроль воспроизведён на develop.
Summary by CodeRabbit
Bug Fixes
Improved inferred variable types across calls, preserving values assigned before and after a call—even when no module variables are involved.
No actionable comments were generated in the recent review.
Walkthrough
VariableFlowPass now records variable values at each call, including in bodies without shared variables. A test checks that a local variable’s inferred declaration type includes values assigned before and after calls.
Changes: Call-boundary type tracking
Layer / File(s)
Summary
Track variable values at calls src/main/java/com/github/_1c_syntax/bsl/languageserver/types/inferencer/VariableFlowPass.java, src/test/java/com/github/_1c_syntax/bsl/languageserver/types/model/CallBoundaryUnionTest.java
VariableFlowPass now tracks changed variables for every body and unions call-boundary values into leaving, even when no shared variables exist. Shared variables are still restored to their scope-wide union after calls. The test checks that a local variable’s inferred type includes both Число and Строка.
A local variable's declared type now keeps values assigned before calls even when the procedure has no module variables. A regression test covers this case, and no merge-blocking risk was found.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title is in Russian and reads as a conventional-commit style fix: it names the fix to types (types inference) and the behavior (keeping local values before calls). The changeset is a change in Var…
Linked Issues check
Stack objective, [#4971]: a local variable's declared type includes values assigned before calls, with or without an unrelated module variable. Status: Addressed by PR #4972 alone (https://github.com/…
Out of Scope Changes check
The changes introduced by PR #4972 touch two files: VariableFlowPass.java and CallBoundaryUnionTest.java. Both files relate to the objective of [#4971].
- VariableFlowPass.java: removes the null guar…
Full details: Title check
Explanation
The title is in Russian and reads as a conventional-commit style fix: it names the fix to types (types inference) and the behavior (keeping local values before calls). The changeset is a change in VariableFlowPass that collects leaving-state changes for every body variable, so local values assigned before calls are retained even without shared module variables. A regression test in CallBoundaryUnionTest covers this. The title matches the main change and the linked issue #4971.
Full details: Linked Issues check
Explanation
Stack objective, [#4971]: a local variable's declared type includes values assigned before calls, with or without an unrelated module variable. Status: Addressed by PR #4972 alone (#4972).
Evidence:
VariableFlowPass.java (diff base to head): changedForLeaving is now always allocated (no longer null when no shared variables exist). applyStatements always clears and sets it. The call-boundary code in the former if (changed == null ...) branch now runs for every body. This records pre-call values into leaving regardless of shared variables.
The post-call reset to the entry facts still applies only to shared variables, as before.
CallBoundaryUnionTest.localDeclarationKeepsValuesBeforeCallsWithoutModuleVariables (new, in the head) has no module variables. It asserts the declaration types are Число and Строка. This matches the issue's negative control.
The existing test repeatedCallsDoNotMergeUnchangedValuesAgain and callsAcrossBranchesAndLoopIterationsKeepIncomingAndResetValues still cover call-boundary behavior and the union limits.
Gap: the new test does not assert the positional type Строка after the second assignment, which the issue also names. The existing code path was not changed for positional types, and the other tests cover related positional behavior. The positional expectation is not directly verified by the new test.
PR #4974 (uncertain, no review evidence) is not needed for this objective. Its membership does not change this result.
Full details: Out of Scope Changes check
Explanation
The changes introduced by PR #4972 touch two files: VariableFlowPass.java and CallBoundaryUnionTest.java. Both files relate to the objective of [#4971].
VariableFlowPass.java: removes the null guard on changedForLeaving, moves the leaving-state tracking out of the shared-variable condition, and updates Javadoc comments to match. These edits implement the objective directly.
CallBoundaryUnionTest.java: adds the regression test for the no-module-variable case. Test support for the objective.
No unrelated behavior change appears in the reviewed diff. Note: the change removes the conditional skip for bodies without shared variables. This can increase work per statement (changedForLeaving.set(0, n) now runs for every body). The repeated-calls test is present to guard the merge count, and the PR reports a passing suite of 2226 tests. This is a performance consideration, not an out-of-scope change.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.
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
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.
Описание
Тип локальной переменной в объявлении терял значения перед вызовами, если в теле не было общих переменных. Добавление неиспользуемой переменной модуля меняло ответ с
СтроканаЧисло | Строка.Значения перед вызовами теперь собираются независимо от наличия общих переменных. Сброс типов самих общих переменных остаётся отдельным шагом. Добавлена регрессия без переменных модуля, прежние проверки границ вызовов и ограничение числа объединений сохранены.
Связанные задачи
Closes #4971
Чеклист
gradlew precommit)Дополнительно
На 7f6854e: весь пакет системы типов — 2226 пройденных тестов, 84 пропущенных, 0 падений; Spotless и precommit прошли. Негативный контроль воспроизведён на develop.
Summary by CodeRabbit