Skip to content

Ada: a nested subprogram takes its parent's body (the parent's branch goes to the nested function) #8913

Closed

Description

@squid-protocol

What is wrong

Ada function extraction gives a nested subprogram's parent its body: the parent's decisions are credited to the nested subprogram instead. Found with an Ada oracle on alire's src (2,202 functions matched; args 1.00 / 0.99; branch recall 0.79, precision 0.89; with these cases removed the agreement is 0.94 / 0.92). This is a function-boundary defect (which lines belong to which function), so it moves every per-function family, not only branch.

Reproduce (pinned scanner; counts read from function_data)

procedure C4 is
   procedure Inner is
   begin
      null;
   end Inner;
begin
   if X > 1 then
      Inner;
   end if;
end C4;

Scanned: C4 struct_branch == 0 and Inner struct_branch == 1. A parser gives C4 1 (the if is C4's) and Inner 0.

Two related shapes the oracle saw but that were not reproduced here on a minimal file (verify before relying on them): an extended return (return R : T do ... end return;) truncating the enclosing function, and an exception handler's when counted as a branch (the branch contract's corollary 1: a handler is not a decision).

Expected

A nested subprogram ends at its own end Inner;, and the lines after it belong to the parent again. The extraction rule is languages/ada.py; the tri-comparison ledger already tracks function boundaries per language, so this belongs with that work.

Part of #8863. Add the case above as a test.

Activity

  1. added
    bug
    core-engine
    on Nov 21, 2026
  2. squid-protocol commented on Nov 22, 2026

    @squid-protocol
    OwnerAuthor

    Claimed by promoter-bot host melek, lease renewed 2026-11-23T12:31Z. It lapses after 6 h without a renewal. To take it back, assign someone or remove the claim:melek label.

  3. squid-protocol commented on Nov 23, 2026

    @squid-protocol
    OwnerAuthor

    Fixed by #9111 (merged as fcc440b), which carried this issue's PR (rebuilt with eight others to re-bless the golden snapshots once).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugclaim:melekcore-enginepriority: medium

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions