Skip to content

test(types): массив, объявленный через себя, покрыт тестами - #4453

Merged
nixel2007 merged 2 commits into
developfrom
fix/recursive-collection-element
Aug 12, 2026
Merged

nixel2007 merged 2 commits into
developfrom
fix/recursive-collection-element

Conversation

@nixel2007

@nixel2007 nixel2007 commented Aug 12, 2026

Copy link
Copy Markdown
Member

Зачем

Функция с описанием Массив из см. ЭтаЖеФункция задаёт значением уравнение T = Массив{элемент: T} — то же, что структура с полем, только ребро идёт через элемент коллекции. Случай работал, но проверен не был: покрывался лишь вариант, где такой массив лежит полем структуры (RecursiveSeeRefInferenceTest), а прямое объявление функции — нет.

Проверяется два свойства:

  • элементом массива снова он сам, то есть рекурсивное ребро не обрублено;
  • обращение по индексу (Ветки()[0][0]) разворачивается по уровню на обращение и не уходит в бесконечность.

Как проверялось

Тесты писались как проба, чтобы выяснить, не даёт ли этот случай вклада в недетерминизм из #4429. Не даёт: оба свойства выполняются, а повторный расчёт при непустом индексе даёт то же самое.

Попутно выяснилось другое: у массива, собранного в коде, тип элемента остаётся Произвольный, потому что Массив.Добавить(значение) состав не уточняет вовсе — на это заведено #4452. К рекурсии это отношения не имеет, элемент там берётся из умолчания реестра.

Правок в коде нет — только тесты и фикстура.

Summary by CodeRabbit

  • Bug Fixes

    • Improved type resolution for recursively defined collection return types.
    • Repeated indexing now correctly resolves to an array type without causing infinite recursion.
    • Ensured repeated return-type calculations produce consistent results.
  • Tests

    • Added coverage for recursive collection types, repeated indexing, and stable return-type resolution.

Функция с объявлением `Массив из см. ЭтаЖеФункция` задаёт значением уравнение
T = Массив{элемент: T} — то же, что структура с полем, только ребро идёт через
элемент коллекции. Случай работал, но проверен не был: покрыт был лишь вариант,
где такой массив лежит полем структуры.

Проверяется, что элементом массива снова он сам и что обращение по индексу
разворачивается по уровню на обращение, а не уходит в бесконечность.

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

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b4928e0e-9874-45c0-a0bd-a69d22f0c067

📥 Commits

Reviewing files that changed from the base of the PR and between ea75567 and 3df1b0e.

📒 Files selected for processing (1)
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/types/RecursiveReturnTypeTest.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/types/RecursiveReturnTypeTest.java

📝 Walkthrough

Walkthrough

The PR adds tests for recursive collection return types. The tests verify self-typed elements, repeated indexing, and stable repeated return-type inference.

Changes

Recursive return types

Layer / File(s) Summary
Recursive type resolution tests
src/test/java/com/github/_1c_syntax/bsl/languageserver/types/RecursiveReturnTypeTest.java
Adds TypeRef and ExpressionTypeInferencer coverage. Tests verify recursive element preservation, bounded repeated indexing, and equal results from repeated inference.

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

Possibly related PRs

🚥 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 Заголовок точно описывает основное изменение: добавление тестов для массива, объявленного через самого себя.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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/recursive-collection-element

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: 1

🤖 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/test/java/com/github/_1c_syntax/bsl/languageserver/types/RecursiveReturnTypeTest.java`:
- Around line 89-107: Update navigationThroughSelfTypedArrayResolves to call
typeService.expressionTypesAt for “Ветки()[0][0]” a second time, then assert the
repeated result matches the first result while retaining the existing
qualified-name assertion.
🪄 Autofix

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: 1449101c-5f1a-4b0c-9e33-e24e23da7f2f

📥 Commits

Reviewing files that changed from the base of the PR and between 10c26e2 and ea75567.

⛔ Files ignored due to path filters (1)
  • src/test/resources/types/RecursiveCollection.bsl is excluded by !src/test/resources/**
📒 Files selected for processing (1)
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/types/RecursiveReturnTypeTest.java

…сылку

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

Повторный вызов expressionTypesAt для этого не годится: он попадает в кэш
выражений и ничего не считает.

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

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

Test Results

 4 086 files  ± 0   4 086 suites  ±0   59m 8s ⏱️ + 4m 42s
 4 239 tests + 3   4 168 ✅ + 3   71 💤 ±0  0 ❌ ±0 
25 434 runs  +18  25 004 ✅ +18  430 💤 ±0  0 ❌ ±0 

Results for commit 3df1b0e. ± Comparison against base commit 10c26e2.

@nixel2007
nixel2007 merged commit b5bab23 into develop Aug 12, 2026
41 checks passed
@nixel2007
nixel2007 deleted the fix/recursive-collection-element branch August 12, 2026 20:11
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