Skip to content

BuildError: Early returns/terminators in if bodies are not supported with structured control flow #658

@jon-wurtz

Description

@jon-wurtz

Use case: early termination

@squin.kernel
def return_zero(n):
    if n <=0:
        return n
    else:
        return return_zero(n-1)

raises BuildError: Early returns/terminators in if bodies are not supported with structured control flow

Yes this can be restructured as

@squin.kernel
def return_zero(n):
    if n > 0:
        return return_zero(n-1)
    return n

That is a structural change in code to comply with compiler needs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    category: bugCategory: this is a bug or something isn't working as expected.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions