Skip to content

fix: lib/stdlib/posix.flow and net.flow never parsed - #549

Merged
godofecht merged 1 commit into
mainfrom
docs/illustrative-imports
Aug 18, 2026
Merged

godofecht merged 1 commit into
mainfrom
docs/illustrative-imports

Conversation

@godofecht

@godofecht godofecht commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

The documentation example checker found a bug in the standard library.

Two shipped modules that have never parsed

lib/stdlib/posix.flow  Expected TokenType.LBRACE, got TokenType.FUNCTION at line 49
lib/stdlib/net.flow    Expected TokenType.LBRACE, got TokenType.FUNCTION at line 51

Both declare externs unbraced:

extern function socket(domain: i32, socket_type: i32, protocol: i32) -> i32
extern function bind(sockfd: i32, addr: ptr<SockAddr_in>, addrlen: i32) -> i32

The language wants a block, which is what every other stdlib module uses:

extern {
    function socket(domain: i32, socket_type: i32, protocol: i32) -> i32
    function bind(sockfd: i32, addr: ptr<SockAddr_in>, addrlen: i32) -> i32
}

29 declarations in posix.flow, 15 in net.flow. Any program importing either module fails immediately. I swept all 138 library modules; these two are the only ones affected.

Why nothing caught it

./flow test --tier2 compiles tests/ and examples/, and no file in either imports posix or net. So a module can be shipped, listed in the generated API page, and be unusable, without any suite noticing.

It surfaced because three tutorials in docs/tutorials/advanced.md do import "stdlib/posix.flow", and the example checker was reporting them as broken documentation when the fault was in the library they import. Fixing the library verified 16 examples across several pages.

Also in here: 17 illustrative imports

Imports that are meant to be hypothetical, now tagged with reasons rather than sitting in the ledger as anonymous debt:

  • catalogues of import forms in LANGUAGE_SPEC.md, AI_FLOW_HANDBOOK.md and language/modules.md (import std.math { sin, cos } beside import verify.nat as nat)
  • relative-import syntax where the sibling module is illustrative
  • flowlm and hello_lib, registry packages not vendored here
  • mylib in the beginner tutorial, which the lesson has the reader create

One block in modules.md shows two imports annotated # forbidden. That is tagged expect-error rather than ignored, and it does fail, so the page now demonstrates the rule instead of asserting it.

Count

before   verified 407   ignored 44   unverified 300
after    verified 423   ignored 60   expect-error 1   unverified 267

The imports and clang failure stages are empty. What remains is parse 202, types 39, vacuous 26.

Validation

  • ./flow test --tier2 --strict 677/677, which covers the lib/stdlib edit
  • Unit suite 1496 passed, 2 skipped
  • check_doc_coverage.py and check_doc_links.py clean
  • Ledger refreshed; --check-ledger reports no new unverified examples

Both declare externs as `extern function open(...)`. The language wants a
braced block, `extern { function open(...) }`, which is what every other
stdlib module uses. Neither file has ever been parseable, so any program
importing them failed:

    lib/stdlib/posix.flow  Expected TokenType.LBRACE, got TokenType.FUNCTION
                           at line 49
    lib/stdlib/net.flow    same, at line 51

29 declarations in posix.flow and 15 in net.flow, now wrapped.

Nothing caught this because tier-2 compiles tests/ and examples/, and no
file in either imports posix or net. The documentation example checker found
it: three tutorials in docs/tutorials/advanced.md import stdlib/posix.flow
and were being reported as broken documentation when the fault was in the
library they import.

Also tags 17 examples whose imports are illustrative rather than real:
catalogues of import forms in the spec and the module system reference,
relative-import syntax where the sibling is hypothetical, `flowlm` and
`hello_lib` package examples, and `mylib` in the beginner tutorial. One
block in modules.md shows two imports annotated `# forbidden`, so it is
tagged expect-error rather than ignored, and it does fail.

Examples: verified 407 to 423, unverified 300 to 267. The imports and clang
failure stages are now empty; what remains is parse 202, types 39,
vacuous 26.

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

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@godofecht
godofecht merged commit fb92d64 into main Aug 18, 2026
21 checks passed
@godofecht
godofecht deleted the docs/illustrative-imports branch August 18, 2026 11:12
@godofecht

Copy link
Copy Markdown
Contributor Author

Correcting an overstatement in this PR's description, now that it has merged.

I wrote that fixing the two modules "verified 16 examples" and moved the count from 407 to 423. That is wrong. I measured it by calling verify() directly in a scratch script, which skips the batched clang stage. The real number after this change is unchanged at 407 verified.

What actually happened is narrower, and still worth having: the 20 blocks that were failing at the imports stage no longer fail there. 17 were tagged as illustrative, and the three docs/tutorials/advanced.md examples that import stdlib/posix.flow now parse and type-check. They then fail at clang instead, so they moved from one failure stage to another rather than becoming verified.

The accurate before and after:

before   verified 407   ignored 44   unverified 300
                        stages: parse 202, types 39, vacuous 26, imports 20, clang 13
after    verified 407   ignored 60   expect-error 1   unverified 283
                        stages: parse 202, types 39, vacuous 26, clang 16

The extern { } syntax fix in this PR is real and stands: both modules genuinely could not parse, and now do. But making them usable needs more, which I have written up as a separate issue rather than guessing at it.

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