Repository navigation
docs: fix the vacuity check, four broken tutorials, and an unsafe stdlib extern - #552
Merged
Merged
Conversation
…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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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,unitormodulewas reported as an empty translation unit. Those all generate real C: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), ahorizondeclaration 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
let sum = 0.0, then reassigned in a looplet mut sum = 0.0let a: vec4<f32> = [1.0, 2.0, 3.0, 4.0]<1.0, 2.0, 3.0, 4.0>test "..." { return 1 }return true/return falseA bracket literal builds an
array<f32, 4>;vec4wants the vector literal. Andtestblocks are synthesized as bool-returning functions, so integer returns never type-checked.The testing example also called
fibonacciwithout defining it. It now carries the definition, so the page shows what it is testing.advanced.mdgoes from 13 unverified to 6.3. lib/stdlib/string.flow violated the project's own CERT rule
sprintfandstrcpysat in a plainexternblock. 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 thanimport "stdlib/string.flow"and callsin.They now sit in their own
@unsafe externblock, with a comment saying why and pointing readers atsnprintf. I swept all oflib/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.flowandnet.flowin #549.Count
Validation
./flow test --tier2 --strict677/677, covering thelib/stdlibeditcheck_doc_links.py,check_doc_coverage.pyclean;ruff check srcclean