Skip to content

refactor(types): срыв расчёта по потоку виден в журнале, а не подменяется типом - #4341

Merged
nixel2007 merged 2 commits into
developfrom
fix/flow-miss-is-an-error
Jul 31, 2026
Merged

refactor(types): срыв расчёта по потоку виден в журнале, а не подменяется типом#4341
nixel2007 merged 2 commits into
developfrom
fix/flow-miss-is-an-error

Conversation

@nixel2007

@nixel2007 nixel2007 commented Jul 31, 2026

Copy link
Copy Markdown
Member

Что и почему

Обращение к переменной, которое расчёт по потоку не смог разместить в графе, уходило в объединение типов по всей области видимости. Подмена скрывала дефект: тип получался, значит и проблемы будто нет.

Теперь такое место пишется LOGGER.error — с документом, позицией обращения и позицией объявления переменной, — а тип остаётся пустым. Туда же ушли перехваты срыва расчёта (StackOverflowError/RuntimeException), раньше молчавшие в debug.

Объединение по области видимости осталось ответом там, где точки исполнения нет по существу: на объявлении Перем оператора не существует, и тип такой переменной — то, с чем она свою область покидает.

Почему это безопасно сейчас

Замер на cpm (analyze, счётчик в месте фоллбэка):

обращений отказов
develop 2 376 525 182
develop + #4337 2 351 882 0

Все 182 отказа на develop — реквизиты управляемой формы, резолвившиеся переменными вида DYNAMIC. С типами форм (#4337) таких мест не остаётся.

Проверки

Полный ./gradlew test локально: 643 класса, падений по коду нет (четыре класса упали от исчерпания inotify на машине и проходят по отдельности).

Summary by CodeRabbit

  • Bug Fixes
    • Improved type inference accuracy for variables at specific code locations.
    • Prevented incorrect fallback to broader-scope or declared types when analysis is unavailable.
    • Improved handling of runtime and stack-overflow errors during inference.

…ется типом

Обращение к переменной, которое расчёт по потоку не смог разместить в графе,
уходило в объединение по всей области видимости. Подмена скрывала дефект
расчёта: тип получался, значит и проблемы будто нет. Теперь такое место
пишется LOGGER.error с документом, позицией обращения и позицией объявления
переменной, а тип остаётся пустым. Туда же ушли перехваты срыва расчёта.

Объединение по области видимости остаётся ответом там, где точки исполнения
нет по существу — на объявлении `Перем`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MnWpDdNSEFohPZHG6voe6y
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@nixel2007, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 49 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 8112a618-9f44-4dec-821e-371ca457e8cf

📥 Commits

Reviewing files that changed from the base of the PR and between f404a58 and d378c4d.

📒 Files selected for processing (1)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/types/inferencer/ExpressionTypeInferencer.java
📝 Walkthrough

Walkthrough

ExpressionTypeInferencer.java changes variable flow type inference so that missing flow results or exceptions during flow-based analysis are logged as errors and return an empty TypeSet, instead of falling back to declared variable types. A helper method formats one-based line:column positions for logging.

Changes

Flow Inference Error Handling

Layer / File(s) Summary
Flow result and exception handling
src/main/java/.../ExpressionTypeInferencer.java
flowTypeAt now logs an error and returns TypeSet.EMPTY when a flow result is absent or an exception occurs, instead of returning declared types. The position-based inference handler applies the same logging and fallback change, using a new helper that converts zero-based LSP positions to one-based line:column strings for log messages.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: claude, sfaqer

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: flow inference failures are logged instead of being replaced by fallback types.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/flow-miss-is-an-error

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/main/java/com/github/_1c_syntax/bsl/languageserver/types/inferencer/ExpressionTypeInferencer.java`:
- Around line 717-720: Update both exception handlers in the type inference
flow, including the variable-based handler around the shown LOGGER.error call
and the position-based handler near the corresponding secondary location, to
include the failing query position in their diagnostic arguments: use
at(Ranges.create(use).getStart()) for the use-based path and at(position) for
the position-based path. Preserve the existing error handling and return
behavior.
- Around line 785-787: Update the public inferVariableAt Javadocs to document
that inference failures log an error and return TypeSet.EMPTY. Apply the same
contract update to the corresponding documentation in docs/ and docs/en/,
keeping both locales consistent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 762c9d88-9992-47df-951d-f8d2ed6b9f53

📥 Commits

Reviewing files that changed from the base of the PR and between 9913f82 and f404a58.

📒 Files selected for processing (1)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/types/inferencer/ExpressionTypeInferencer.java

Comment on lines +785 to +787
LOGGER.error("Расчёт типа по потоку сорвался на переменной {} (объявлена {}): {}",
variable.getName(), at(variable.getSelectionRange().getStart()), owner.getUri(), e);
return TypeSet.EMPTY;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Document the new failure result in the public contract.

This handler now returns TypeSet.EMPTY and emits an error log. The public inferVariableAt Javadocs above this method do not describe this result or the logging side effect. Update those Javadocs and the corresponding documentation in docs/ and docs/en/.

As per coding guidelines, public Java APIs must document their contract, and behavior changes must update both documentation locales.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/java/com/github/_1c_syntax/bsl/languageserver/types/inferencer/ExpressionTypeInferencer.java`
around lines 785 - 787, Update the public inferVariableAt Javadocs to document
that inference failures log an error and return TypeSet.EMPTY. Apply the same
contract update to the corresponding documentation in docs/ and docs/en/,
keeping both locales consistent.

Source: Coding guidelines

Оба перехвата писали переменную, её объявление и документ, но не место, где
тип спросили, — без него по журналу не найти, на чём расчёт сорвался. Заодно
в контракте обоих inferVariableAt описан пустой ответ при срыве.
@nixel2007
nixel2007 merged commit 95babf8 into develop Jul 31, 2026
20 checks passed
@nixel2007
nixel2007 deleted the fix/flow-miss-is-an-error branch July 31, 2026 10:11
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant