Skip to content

docs: fix the vacuity check, four broken tutorials, and an unsafe stdlib extern - #552

Merged
godofecht merged 1 commit into
mainfrom
docs/vacuous-and-type-errors
Aug 18, 2026
Merged

godofecht merged 1 commit into
mainfrom
docs/vacuous-and-type-errors

Conversation

@godofecht

@godofecht godofecht commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Three unrelated things the example checker turned up. All real, all separable on review.

1. My vacuity check was wrong

It required a declaration from a whitelist of "substantive" kinds, so a block that was only a const, type alias, distinct type, unit or module was reported as an empty translation unit. Those all generate real C:

const PI: f32 = 3.14159   ->  static const float PI = 3.14159;
type Bytes = array<u8>    ->  typedef uint8_t* Bytes;
unit Meter                ->  typedef double Meter;

A page about type aliases legitimately shows one type alias. The check was conflating "emits no functions" with "says nothing".

Vacuous now means the block declares nothing at all, which is only true of a block that is entirely comments. That recovered 19 examples. The five still vacuous genuinely are comment-only, and are tagged: three proof metadata headers (# @means, # @tier), a horizon declaration that expands to nothing, and a block of commented-out illegal code under "Illegal under --strict @rt_safe checking".

2. docs/tutorials/advanced.md taught four things that do not compile

Line Was Is
192 let sum = 0.0, then reassigned in a loop let mut sum = 0.0
318 let a: vec4<f32> = [1.0, 2.0, 3.0, 4.0] <1.0, 2.0, 3.0, 4.0>
334 same, three more times in the SIMD example vector literals
398 test "..." { return 1 } return true / return false

A bracket literal builds an array<f32, 4>; vec4 wants the vector literal. And test blocks are synthesized as bool-returning functions, so integer returns never type-checked.

The testing example also called fibonacci without defining it. It now carries the definition, so the page shows what it is testing.

advanced.md goes from 13 unverified to 6.

3. lib/stdlib/string.flow violated the project's own CERT rule

sprintf and strcpy sat in a plain extern block. The type checker requires unbounded FFI under @unsafe extern (CERT, #276), so every program importing the module failed strict checking — including the beginner tutorial's first standard-library example, which does nothing more exotic than import "stdlib/string.flow" and call sin.

They now sit in their own @unsafe extern block, with a comment saying why and pointing readers at snprintf. I swept all of lib/stdlib; this was the only module that tripped the rule.

This is the third stdlib bug this documentation work has found, after the unparseable posix.flow and net.flow in #549.

Count

before   verified 407   ignored 60   unverified 283
after    verified 430   ignored 65   expect-error 1   unverified 255

Validation

  • ./flow test --tier2 --strict 677/677, covering the lib/stdlib edit
  • Unit suite 1496 passed, 2 skipped
  • check_doc_links.py, check_doc_coverage.py clean; ruff check src clean
  • Ledger refreshed

…lib extern

Three unrelated things the example checker turned up, all real.

The vacuity check was wrong. It required a declaration from a whitelist of
"substantive" kinds, so a block that was only a const, type alias, distinct
type, unit or module read as an empty translation unit. Those all generate
real C:

    const PI: f32 = 3.14159   ->  static const float PI = 3.14159;
    type Bytes = array<u8>    ->  typedef uint8_t* Bytes;
    unit Meter                ->  typedef double Meter;

A page about type aliases legitimately shows one type alias. Vacuous now
means the block declares nothing at all, which is only true of a block that
is entirely comments. That recovered 19 examples. The five that remain
vacuous really are comment-only: three proof metadata headers, a `horizon`
declaration that expands to nothing, and a block of commented-out illegal
code. Those are tagged.

docs/tutorials/advanced.md taught four things that do not compile:

  - `let sum = 0.0` then reassigned in a loop; needs `let mut`
  - `let a: vec4<f32> = [1.0, 2.0, 3.0, 4.0]`; a bracket literal builds an
    array, and vec4 wants the vector literal `<1.0, 2.0, 3.0, 4.0>`
  - the same in the SIMD example, three more times
  - `test "..." { return 1 }`; test blocks are synthesized as bool-returning
    functions, so the arms return true and false

The testing example also called `fibonacci` without defining it, so it now
carries the definition and shows what it is testing.

lib/stdlib/string.flow declared sprintf and strcpy in a plain extern block.
The type checker requires unbounded FFI under `@unsafe extern` (CERT, #276),
so every program importing the module failed strict checking, including the
beginner tutorial's first standard-library example. They now sit in their
own `@unsafe extern` block with a comment saying why and pointing at
snprintf. It is the only stdlib module that tripped the rule.

Examples: verified 407 to 430, unverified 283 to 255.

Unit 1496 passed, tier-2 677/677, links and coverage clean.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@godofecht
godofecht merged commit 0ffeddd into main Aug 18, 2026
21 checks passed
@godofecht
godofecht deleted the docs/vacuous-and-type-errors branch August 18, 2026 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant