You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Stage-A cgen emits 0 for identifiers named like sort modifiers (descending, asc, unique, ...) #994
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
FlowcProgressiondescending=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
fix(stage-a): match Python operator precedence; keep sort modifier wo…
fix(stage-a): match Python operator precedence; keep sort modifier wo…