Repository navigation
Description
Summary
Close the remaining no_std tier leaks so heap, OS, async, and std-only modules cannot be used when §18.7 says they are unavailable. The compiler has a partial core/alloc/std tier model, but it relies mostly on symbol checks and misses constructed builtins, explicit std module imports, and async syntax when --no-std still leaves the runtime flag enabled.
Spec
§18.7 says --no-std / std = false keeps core primitives, ownership, Option/Result, slices, fixed arrays, tuples, ranges, pointers, comptime, c_import, panic handler support, Never, and unsafe. It excludes str/String, Vec, HashMap, Box, printing, std.io, std.fs, std.net, async fn/.await, and std.sync unless an explicit alloc/core exception is specified.
Current state
The infrastructure exists but is partial. Prelude mode switches to core or alloc when no_std is set (src/compiler/Compilation/Config.w:36). Sema has symbol-tier helpers for alloc and std (src/Sema.w:705, src/Sema.w:712, src/Sema.w:720) and validates panic handler/entry/global allocator requirements (src/SemaCheck.w:511). String literals and regex are gated (src/SemaCheck.w:2822, src/SemaCheck.w:2839, src/SemaCheck.w:2868).
The leak is that tier checks are not centralized on every surface. symbol_requires_std_tier only knows regex and print-like names (src/Sema.w:720), not modules like std.io, std.net, or std.sync. require_async_runtime only checks runtime_available (src/SemaCheck.w:30), so --no-std without --no-runtime can still allow async syntax even though §18.7 marks async as std/runtime-only. Generic/builtin collection construction can bypass simple imported-symbol checks.
Implementation plan
- Introduce a single tier classifier for modules, types, functions, syntax forms, and compiler intrinsics:
core,alloc, orstd. Do not scatter more one-off string checks. - Extend module import resolution/frontend checks so explicit
use std.io,use std.net,use std.fs,use std.sync, and other std-only modules fail under--no-stdunless an allowed alloc/core subset is chosen. - Gate syntax and builtins directly:
async fn,async:blocks,.await,select await, channels, task APIs, and sync primitives should require std/runtime under §18.7, not onlyruntime_available. - Gate generic builtins by constructed base type, not by name lookup only:
Vec[T],HashMap[K,V],HashSet[T],Box[T], and ownedstrrequire alloc, and OS-backed modules require std. - Preserve allowed core behavior: fixed arrays, slices, tuples, ranges, raw pointers,
Option/Result,c_import, and borrowed&strliterals must continue to work. - Make diagnostics explicit:
Vec requires alloc; use --alloc or set alloc = true with std = false,async requires std/fiber runtime,std.io requires std. - Add regression coverage before broad refactors so every leak named in the original issue fails red first.
Test plan
Add compile-error tests:
err_no_std_vec_builtin_leak.w;err_no_std_hashmap_builtin_leak.w;err_no_std_async_fn_leak.w;err_no_std_await_leak.w;err_no_std_use_std_io_leak.w;err_no_std_use_std_net_leak.w;err_no_std_use_std_sync_leak.w.
Keep/extend existing no_std positives: test/behavior/behav_no_std_core_prelude.w and test/behavior/behav_no_std_alloc_prelude.w.
Add one alloc-mode positive where std = false, alloc = true permits Vec but still rejects std.io and async.
Acceptance criteria
- Every §18.7 std-only category is rejected under core no_std.
- Alloc no_std permits allocation-backed types only when
alloc = trueand allocator requirements are met. - OS/fiber-backed modules and syntax remain rejected under no_std.
- Diagnostics tell users which tier is required.
with build && with build :fixpoint && with build :testpass.
Dependencies
None.
Traceability
From the requirements campaign (docs/requirements.md, spec v7.1). Affected requirement IDs: 18.7.1.24, 18.7.1.25, 18.7.1.28, 18.7.1.29, 18.7.1.30, 18.7.1.31.
Activity
Requirements triage campaign: checkbox, verdict, and issue-link every…
ehartford commentedon Jun 13, 2026
Implemented in afdcb48. no_std now rejects std-only module imports from the resolved module graph, gates async syntax/declarations with a std/fiber-runtime diagnostic, and gates constructed alloc-backed builtins before unknown-type fallback. Added negative coverage for Vec, HashMap, async fn, await, std.io, std.fs, std.net, std.sync, plus alloc-mode async rejection, while preserving core/alloc no_std positives. Verification passed: build, fixpoint, full test suite, and test-green.
test: coverage-sweep batch 5 (#485 #486 #487 #500 #505 #510)