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
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
fix(stage-a): match Python operator precedence; keep sort modifier wo…
fix(stage-a): match Python operator precedence; keep sort modifier wo…