Skip to content

flowc: println of an f64/f32 struct field prints with %d #992

Closed

Description

@godofecht

On the flowc host, println picks the printf format from the argument's type, but a struct field access falls back to %d.

struct S {
    a: f64,
    b: f32
}

function main() -> i32 {
    let s: S = S { a: 1.5, b: 2.5 }
    let x: f64 = 3.5
    println(x)
    println(s.a)
    println(s.b)
    return 0
}

flowc emits:

printf("%f\n", x);
printf("%d\n", (s).a);
printf("%d\n", (s).b);

and the program prints 3.500000, 0, 0. The Python host prints the field values. Seen while porting flow blocks to flowc (#681): a flow's state is a struct field, so println(osc.x) prints 0. Workaround: copy the field into a typed local first, or print a scaled integer.

Expected: flowc_cgen_emit_print_intrinsic resolves the field's declared type (the struct is known to the typechecker) and uses %f for f64/f32 fields, as it does for locals.

Activity

  1. added 2 commits that reference this issue on Sep 29, 2026
    8ed924b
    d7fcdb2
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