Skip to content

Tests: no std coverage coverage (§18) #510

Closed

Description

@ehartford

Tests: no std coverage (§18)

Summary

§18.7's "what you keep (core)" table promises a large language surface under --no-std/std = false — traits, slices, tuples, ranges, math, bitwise, pointers, comptime, c_import, ownership, unsafe, comptime if — and almost none of it has tests in freestanding mode. The std = false manifest path is parsed but untested entirely. This issue builds the positive core-surface matrix plus the manifest-driven test; the negative gating tests for the known leak paths belong to #458 and are cross-referenced, not duplicated.

Spec

§18.7 (docs/with-specification.md:9978-10123): core-tier table (:9996-10019), tier table (:10094-10100), manifest forms (:9982-9994):

[package]
name = "my-firmware"
std = false

or with build --no-std ....

Requirement IDs: 18.7.1.2 (std = false in with.toml), 18.7.1.7 (traits), 18.7.1.9 (slices), 18.7.1.11 (tuples), 18.7.1.12 (ranges), 18.7.1.13 (math/min/max/abs), 18.7.1.14 (bitwise), 18.7.1.15 (pointers), 18.7.1.16 (comptime), 18.7.1.17 (c_import), 18.7.1.18 (ownership), 18.7.1.21 (unsafe blocks), 18.7.1.22 (comptime if).

Current state

  • Existing coverage (all there is):
    • test/spec/spec_ss18_7_freestanding_mode.w — check-only smoke: primitives, Option, fixed array, &str literal, @[panic_handler]/@[entry].
    • test/behavior/behav_no_std_core_prelude.w, behav_no_std_alloc_prelude.w — prelude tiers.
    • test/compile_errors/err_no_std_{print_requires_std, vec_requires_alloc, owned_str_requires_alloc, regex_requires_std, missing_panic_handler, missing_entry, alloc_requires_global_allocator}.w — negative gating that exists today.
  • Campaign survey (g13): manifest std=false parsed (project_config_apply_entry, src/compiler/ProjectConfig.w:120-126) but untested; core traits/slices/tuples/ranges untested under no-std; min/abs verified live only.
  • Gating mechanics for orientation: Sema.no_std (src/Sema.w:541), core_without_alloc (Sema.w:705-710), symbol_requires_alloc_tier/symbol_requires_std_tier (Sema.w:712-728) enforced at type resolution (SemaCheck.w:265-310); async gate keys on runtime_available (SemaCheck.w:30-33), not no_std; structural requirements in validate_no_std_requirements (SemaCheck.w:511-549).
  • Known leaks (verified live during enrichment, with v0.14.0) — these are Bug: no_std gating leaks (builtin Vec/HashMap/async/std.io compile under --no-std) (§18.7) #458's scope, listed here so this issue's tests don't mask them:

Implementation plan

  1. Positive core-surface spec tests, one file per table row, //! check-only + //! args: --no-std, each with the standard freestanding skeleton (@[panic_handler] fn on_panic -> Never: unreachable() + @[entry] fn start -> i32, pattern: test/spec/spec_ss18_7_freestanding_mode.w):
    • spec_ss18_7_core_traits.w — derive/impl Eq, Ord, Hash, Debug, Default, Copy, Clone on a struct; a Drop impl whose drop is statically injected (18.7.1.7).
    • spec_ss18_7_core_slices.w — &[T] views over [T; N], indexing, iteration, .len() (18.7.1.9).
    • spec_ss18_7_core_tuples.w — construction, destructuring, nested (18.7.1.11).
    • spec_ss18_7_core_ranges.w — 0..10, 0..=10, for-loop iteration, bounds (18.7.1.12).
    • spec_ss18_7_core_math.w — int/float arithmetic, min, max, abs (18.7.1.13).
    • spec_ss18_7_core_bitwise.w — band/bor/bxor/shl/shr/bnot (or operator forms) across i8..u64 (18.7.1.14).
    • spec_ss18_7_core_pointers.w — *T/*mut T, safe address arithmetic/comparison, unsafe deref/conversion per §16.11 (18.7.1.15, 18.7.1.21 — unsafe block usage here covers both).
    • spec_ss18_7_core_comptime.w — comptime eval, const, and comptime if branch selection (18.7.1.16, 18.7.1.22).
    • spec_ss18_7_core_ownership.w — moves, borrows, explicit drop of a Drop type (18.7.1.18).
    • spec_ss18_7_core_c_import.w — c_import of a tiny local header (declaration-only use so it stays check-only/hermetic) (18.7.1.17).
      Where runtime execution adds value (math, bitwise, ranges), add an //! expect-exit: 0 variant if freestanding binaries are runnable on the host with @[entry]; if they are not, keep check-only and note why in the file header.
  2. Manifest test (18.7.1.2) — needs a project dir, so it goes in a build/selfhost.w action (pattern: run_cli_selfhost_one_liner_action, build/selfhost.w:409): write a project with with.toml containing std = false and a source using print → with build fails with the std-tier diagnostic (same one err_no_std_print_requires_std.w asserts under the flag); variant with std = false + alloc = true + @[global_allocator] → Vec-typed code builds. This proves manifest keys drive the same gating as --no-std/--alloc flags.
  3. Alloc-tier positive: spec_ss18_7_alloc_tier.w (//! args: --no-std --alloc) — Vec, String, HashMap usable with @[global_allocator] present (extends behav_no_std_alloc_prelude.w to the spec's promised type list).
  4. Update test/coverage_matrix.md / coverage_manifest.txt if those manifests enumerate spec sections.

Test plan

The files above are the deliverable. Directive conventions: //! check-only, //! args: --no-std [--alloc], //! expect-check-fail: for any negative twin, //! expect-exit/expect-stdout for runnable variants. Each file names its requirement ID(s) in the header comment.

Acceptance criteria

Dependencies

#458 (no_std gating leaks) owns the negative tests for Vec-via-inference / use std.* / async under no_std — coordinate so the two test sets compose without overlap. Related: #457 (FixedString core-tier tests), #475 (Box gating), #519 (prelude shadowing tests), #425 (freestanding targets eventually need --target).

Traceability

From the requirements campaign (docs/requirements.md, spec v7.1). Affected requirement IDs: 18.7.1.11, 18.7.1.12, 18.7.1.13, 18.7.1.14, 18.7.1.15, 18.7.1.16, 18.7.1.17, 18.7.1.18, 18.7.1.2, 18.7.1.21, 18.7.1.22, 18.7.1.7, 18.7.1.9.

Activity

  1. ehartford commented on Jul 3, 2026

    @ehartford
    ContributorAuthor

    Closing the core-language surface: under --no-std, tuples/ranges/bitwise+arithmetic operators/traits/derive (spec_ss18_7_core_language) and raw pointers+slices (spec_ss18_7_core_pointers_slices) pinned (3628d82), freestanding @[panic_handler]+@[entry]. IMPORTANT: fixtures use OPERATORS only — min/max/abs are std.math (not core prelude), so a core fixture using them would encode the #458 tier-leak as expected-pass. Residual: manifest std=false equivalence (18.7.1.2) needs a with.toml project build, not a .w — separate deliverable. §18.7.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions