Skip to content

Stage-A: a variable named desc compiles to 0 #968

Closed

Description

@godofecht

Stage-A flowc emits the identifier desc as the literal 0 when it appears in an expression. The name is probably caught by keyword handling (sort direction), so a local called desc silently becomes a null pointer.

Repro (desc_ident.flow):

function main() -> i32 {
    let desc: string = "hello"
    let s: string = "[" + desc + "]"
    print("x")
    return 0
}
FLOWC_TYPECHECK=1 FLOWC_IN=desc_ident.flow FLOWC_OUT=desc_ident.c compiler/bootstrap/flowc_stage_a
grep 'const char\* s =' desc_ident.c
const char* s = __flowc_str_concat(__flowc_str_concat("[", 0), "]");

flowc exits 0, and so does the C compiler. At run time the concatenation reads a null pointer. The expected output is __flowc_str_concat(__flowc_str_concat("[", desc), "]"), or a compile error if desc is reserved.

Workaround: rename the variable. Found while porting scripts/build_demo_overview.py to Flow.

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