Skip to content

std.sync (§7.1, §7.5, §7.7, §14.3, §14.17): Mutex.lock() and RwLock.read() / RwLock.write() guard methods missing #3039

Closed

Description

@ehartford

Found during the #2987 manual audit of docs/spec/007_with-scoped-access.md (§§7.1, 7.5, 7.6, 7.7), docs/spec/005_ephemeral.md (§5.3), docs/spec/012_closures.md (§12.3), and docs/spec/014_concurrency.md (§14.3).

Gap

Across the specification (001_design-goals.md, 005_ephemeral.md, 007_with-scoped-access.md, 012_closures.md, 014_concurrency.md, denied-patterns.md), lock guards are acquired as:

  • with lock.lock() as data: / with lock.lock() as mut data: on Mutex[T]
  • with rw.read() as data: on RwLock[T] (returning RwReadGuard[T] / RwLockReadGuard[T])
  • with rw.write() as mut data: / with rw.write() as data: on RwLock[T] (returning RwWriteGuard[T] / RwLockWriteGuard[T])

In lib/std/sync.w:

  1. Mutex and RwLock expose only enter() and enter_mut(), so lock.lock(), rw.read(), and 0-arg rw.write() all fail with unknown method.
  2. Whole-value replacement is named Mutex.set(value) on Mutex (lib/std/sync.w:202) but RwLock.write(value) on RwLock (lib/std/sync.w:305), occupying the 0-arg RwLock.write() guard method name.
  3. MutexGuardMut[T] and RwWriteGuard[T] implement ScopedMut[T] only, not Scoped[&T], so with lock.lock() as data: (§7.7) and with lock.write() as data: (§7.5, §14.3) cannot bind an immutable &T view.
  4. 005_ephemeral.md:45 names RwLockReadGuard[T] and RwLockWriteGuard[T], while lib/std/sync.w exports only RwReadGuard[T] and RwWriteGuard[T].
  5. src/SemaCheck.w:35441, 35602-35604 checks may_suspend and view-escape on enter/enter_mut/set/write and must cover lock/read/write/set.

Activity

  1. added
    spec-gap
    on Nov 5, 2026
  2. added a commit that references this issue on Nov 5, 2026
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

    spec-gap

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions