Skip to content

std.sync does not compile in a --no-prelude program: its Result matches read the prelude's Ok/Err #2555

Closed

Description

@ehartford

A --no-prelude program whose module imports std.sync fails inside std.sync itself (installed compiler v0.15.3.0-g603b5574a; the module is a package module assembled as the STC test lane does, with build --no-prelude -O1 lib/std/stc_testing/algorithm_test.w):

error: variant pattern requires an enum subject
 --> <embedded-std>/std/sync.w:237:17
237 |                 Ok(_) => return RwReadGuard { ptr: self.ptr }
error: variant pattern requires an enum subject
 --> <embedded-std>/std/sync.w:238:17
238 |                 Err(_) => ()

(and the same at 334 and 344). The Result matches in std.sync read the prelude's Ok/Err, which a --no-prelude compilation does not provide, so the stdlib module is unusable from a program compiled that way, which every corpus test lane is (c-algorithms, tommyds, stc). Expected: a stdlib module names what it uses (use std.result or the builtin spelling) and compiles whatever the prelude mode, as std.libc and std.collections do.

Found wiring an atomic failure counter into the STC test harness (test/corpora/stc_harness); the harness uses std.collections' Atomic[i64] instead.

Activity

  1. ehartford commented on Oct 25, 2026

    @ehartford
    ContributorAuthor

    Triage 2026-10-25, with v0.15.3.0 (main a261b65): reproduced.

    $ cat main.w
    use std.sync
    fn main:
        let m = Mutex.new(1)
    $ with check --no-prelude main.w
    error: variant pattern requires an enum subject
     --> <embedded-std>/std/sync.w:237:17
    237 |                 Ok(_) => return RwReadGuard { ptr: self.ptr }
    

    post-release: --no-prelude is a niche mode; qualifying the patterns in std.sync is small.

  2. added this to the post-v0.16.0 milestone on Oct 28, 2026
  3. added a commit that references this issue on Nov 11, 2026
  4. ehartford commented on Nov 11, 2026

    @ehartford
    ContributorAuthor

    Merged to main ae20d89 (#3249): std.sync and eleven more std modules (alloc, channel, compiler, context, fs, generators, http, io, json, result, string, tls) import what they use; a sweep of every lib/std module under --no-prelude is clean. Fixtures test/phase/no_prelude_std_sync.w and no_prelude_std_modules.w.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions