Skip to content

describe can emit empty top-level else after shared continuation traversal #497

@hjotha

Description

@hjotha

Problem

Top-level IF traversal can emit an empty else branch when the false branch points at a continuation that has already been emitted while traversing the true branch.

The false destination is not necessarily the selected merge, so the existing falseFlow.DestinationID != mergeID check can decide that an ELSE body exists. But the actual false-branch traversal then produces no statements because the continuation is already visited.

This creates MDL like:

if $UseNestedPath then
  ...
else
end if;

A later exec/describe pass removes the empty branch, leaving a roundtrip mismatch.

Expected behavior

Top-level IF traversal should behave like nested IF traversal: only keep else if traversing the false branch actually emits statements.

Proposed fix

Emit the else line tentatively, traverse the false branch with an isolated visited map, and remove the line again if no statements were produced.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions