Skip to content

результат Делегата при вызове процедуры +тест - #1809

Open
Mr-Rm wants to merge 1 commit into
EvilBeaver:developfrom
Mr-Rm:v2/fix-delegate-NRE
Open

Mr-Rm wants to merge 1 commit into
EvilBeaver:developfrom
Mr-Rm:v2/fix-delegate-NRE

Conversation

@Mr-Rm

@Mr-Rm Mr-Rm commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Исправляет падение по NRE при использовании результата вызова Процедуры через Делегат:

Процедура ТестоваяПроцедура() Экспорт
КонецПроцедуры

Действие = Новый Действие(ЭтотОбъект, "ТестоваяПроцедура");
Результат = Действие.Выполнить(); // будет Результат == null, без ошибки
Сообщить(Результат = Неопределено); // падает здесь

Ошибка в строке: 6 / Внешнее исключение (System.NullReferenceException): Object reference not set to an instance of an object.}

DelegateAction создаёт лямбду с вызовом метода всегда через CallAsFunction. Для процедур возвращаемое значение будет null, который не конвертировался в Неопределено
Исправлено внутри стековой машины, т.к. это исправляет ещё и возможность аналогичного падения динамического вызова модулем #native метода подключенного модуля #stack

Summary by CodeRabbit

  • Bug Fixes
    • Procedure calls now return an undefined result consistently, including when invoked through an action. This avoids exposing a null or empty value as the result of a procedure call and makes the returned value match the expected behavior for procedures. Function calls continue to return their calculated results.

@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

ExecuteMethod now initializes procedure results to BslUndefinedValue.Instance. A new test invokes an exported procedure through Действие.Выполнить() and checks that the result is Неопределено.

Changes: Procedure action result

Layer / File(s) Summary
Initialize and test procedure results
src/ScriptEngine/Machine/MachineInstance.cs, tests/delegate-action.os
ExecuteMethod initializes procedure results to BslUndefinedValue.Instance. The test suite registers a test that invokes an exported procedure through Действие.Выполнить() and checks that the result is Неопределено.

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

Change: Bug fix

Suggested reviewers: evilbeaver, sfaqer

Merge Risk: Minimal · up to e1171

Calling a procedure through a delegate now returns Неопределено instead of null, so comparing the result no longer throws a NullReferenceException. The change is small and tested, and I found no merge-blocking risk.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "результат Делегата при вызове процедуры +тест" ("Delegate result when calling a procedure + test") matches the main change. The fix makes a procedure invoked through a delegate return Неопр…
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.
Full details: Title check

Explanation

The title "результат Делегата при вызове процедуры +тест" ("Delegate result when calling a procedure + test") matches the main change. The fix makes a procedure invoked through a delegate return Неопределено (undefined) instead of null, and the PR adds a test for that case. The title names the behavior and the test, so a teammate scanning history can identify the primary change.

Finishing Touches

Generate unit tests (beta)

  • 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.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c9929cbc-1454-4172-88b6-046efc78095f
Commits

Reviewing files that changed from the base of the PR and between df5432c and e1171e4.

Files selected for processing: 2

  • src/ScriptEngine/Machine/MachineInstance.cs
  • tests/delegate-action.os

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@sonar-openbsl-ru-qa-bot

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