Skip to content

Stage-A cgen emits 0 for identifiers named like sort modifiers (descending, asc, unique, ...) #994

Closed

Description

@godofecht

Stage-A cgen emits the literal 0 for any identifier whose name is a sort modifier, wherever it appears. The list in compiler/src/cgen.flow (the AST_IDENT branch of the expression emitter) covers at least general, adaptive, descending, ascending, unique, asc and desc.

The intent is to turn sort modifiers passed as call arguments (xs |> sort descending lowers to sort(xs, descending)) into a placeholder. Applied to every identifier, it silently rewrites ordinary variables.

Reproduction: tests/lang/test_range_sums_port.flow declares let descending: FlowcProgression = ... and then reads descending.valid. Stage-A emits

FlowcProgression descending = flowc_range_normalize(10, 0, (0 - 3));
if ((0).valid != 1) {

which fails to compile. A scalar variable with one of these names would compile and read as 0.

Suggested fix: substitute these names only when the identifier is an argument of a sort / sortBy call produced by the pipeline lowering. Everywhere else they are ordinary names.

Found while measuring parse coverage (compiler/scripts/parse_coverage.sh): the file parses now, so the bug became visible.

Activity

  1. added 2 commits that reference this issue on Sep 29, 2026
    28c32e1
    605589d
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

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions