Skip to content

flowc strict check: sizeof<T>() is an undefined function (sizeof_i64) #952

Closed

Description

@godofecht

Two checker gaps that block the pthread size test.

function main() -> i32 {
    if sizeof<i64>() != 8 { return 1 }
    return 0
}
import "stdlib/concurrent.flow"
function main() -> i32 {
    let m: Mutex = mutex_new()
    mutex_destroy(m)
    return 0
}

Observed: first program: flowc tc: unbound call at 2:8 (sizeof). Second: flowc tc: unbound call at 3:20 (mutex_new), and again for mutex_destroy.

Reproduce with the Stage-A compiler built from compiler/bootstrap/flowc_stage_a.c:

cc -O2 -o compiler/build/flowc_bootstrap compiler/bootstrap/flowc_stage_a.c
FLOWC_BUNDLE=1 FLOWC_DIR=. FLOWC_IN=repro.flow FLOWC_OUT=repro.c compiler/build/flowc_bootstrap
cc -O0 -o repro repro.c -lm && ./repro; echo $?

The Python host (./flow test-lang) handles the same program correctly.

Found while porting the Python run tests to tests/lang/. The Python test stays until this is fixed: tests/unit/test_pthread_binding.py::test_the_stdlib_locks_are_at_least_as_large_as_the_objects_they_hold.

Activity

  1. godofecht commented on Sep 30, 2026

    @godofecht
    ContributorAuthor

    Fixed on main (#966 added compiler/fixtures/stage_a_sizeof.flow; stdlib module resolution landed with #1027). Both names bind now:

    $ compiler/scripts/flowc_emit.sh --strict sizeof.flow sizeof.c && cc sizeof.c && ./a.out; echo $?
    0
    $ ./flow run mutex.flow      # import concurrent; mutex_new, mutex_lock(&m), mutex_unlock(&m), mutex_destroy(&m)
    Exit code: 0
    

    The second program in this issue passes m by value to mutex_destroy(m: ptr<Mutex>); with &m it runs. flowc's strict check does not flag the by-value argument (cc does), which is a separate checker gap.
    Checked on main at ee5048d with the flowc built by compiler/scripts/bootstrap_from_c.sh --verify.

  2. godofecht commented on Sep 30, 2026

    @godofecht
    ContributorAuthor

    Reopening: my check above was wrong about strict mode. My harness dropped the --strict flag, so both runs were in the default lenient mode. Rechecked on main at ee5048d with the flag really passed:

    $ compiler/scripts/flowc_emit.sh sizeof.flow sizeof.c && cc sizeof.c && ./a.out; echo $?
    0
    $ compiler/scripts/flowc_emit.sh --strict sizeof.flow sizeof.c
    sizeof.flow:2:8: error: Undefined function 'sizeof_i64'
    sizeof.flow:2:22: error: If condition must be bool, got i32
    flowc emit: typecheck failed
    
  3. added
    flowc-bug
    on Sep 30, 2026
  4. changed the title [-]Stage-A: sizeof<T>() and stdlib/concurrent.flow mutex functions are unbound[/-] [+]flowc strict check: sizeof<T>() is an undefined function (sizeof_i64)[/+] on Sep 30, 2026
  5. godofecht commented on Sep 30, 2026

    @godofecht
    ContributorAuthor

    Reproduced on main in strict mode: sizeof<i64>() gave "Undefined function 'sizeof_i64'". Lenient mode already worked. Fixed in #1082: sem_check types sizeof() as i64. The concurrent.flow program works on main when it passes &m. Passing m by value is now a strict error (#1080). Regression: tests/lang/test_sizeof_generic.flow.

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

    flowc-bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions