Repository navigation
Description
Summary
Give Send, Sync, and ScopedSend real semantic force instead of mostly vacuous marker handling. Today Send and ScopedSend are interned as language traits, but Sync is not, and there are few or no owned non-Send witnesses until Rc/Arc land. The compiler needs a substantive trait model so tasks, channels, locks, generators, and future shared ownership enforce the §14.16 tables.
Spec
§14.16 defines Send as safe to move across threads, Sync as safe to share via &T across threads, and ScopedSend as safe to move to a bounded lexical thread. §14.20 and §14.22 apply those rules to generators and tasks. The table requires examples such as Rc[T] being non-Send/non-Sync and Arc[T] being Send/Sync only when T: Send + Sync.
Current state
Sema.init_intrinsic_symbols registers Send and ScopedSend as language-level traits but not Sync (src/Sema.w:1531, src/Sema.w:1535). Copy/Drop get real semantic logic; Send/Sync mostly reduce to existing ephemerality checks. Channels reject ephemeral sends and have a placeholder channel send requires Send value diagnostic (src/SemaCheck.w:11236), but without owned non-Send types that check has little substance.
Generic trait selection exists (src/SemaCheck.w:8922), but #391's generic-instance erasure limits correct per-instantiation reasoning. Future Rc/Arc (#470) and Box (#475) provide the needed non-Send and conditional-Send witnesses.
Implementation plan
- Intern
Syncas a language trait besideSendandScopedSendinsrc/Sema.w. - Add semantic helpers
type_is_send,type_is_sync, andtype_is_scoped_sendthat handle primitives, references, raw pointers, tasks, generators, arrays/tuples, structs, enums, and generic instances. - Make traits structural by default only where the spec allows it. A struct is Send if all stored fields are Send; Sync if all shared fields are Sync; references depend on referenced type and lifetime/ephemeral rules.
- Add explicit negative and conditional impl behavior for future
Rc[T],Arc[T],Box[T],Task[T],ScopedTask[T], channels, locks, and generators. Do not use name-only heuristics. - Wire the helpers into channel send (Bug: channel send does not consume; non-integer element types mistyped (§14.15) #419), Task sendability (Enforce Task sendability conditions (§14.7, §14.22) #480), OS-thread spawn, scoped thread spawn, generator sendability, and lock sharing.
- Improve diagnostics to name the reason:
type Rc[T] is not Send,field foo is not Sync, orTask captures non-Send value. - Sequence concrete non-Send witnesses behind Implement Rc[T] and Arc[T] (+ Shared[T] alias) (§8.2, §8.4, §14.16) #470 so tests can prove rejection with real owned types instead of artificial compiler-only fixtures.
Test plan
After #470, add tests:
err_send_rc_to_channel.w;err_spawn_os_captures_rc.w;err_sync_shared_rc_ref.w;- positive
Arc[i32]send/sync; - negative
Arc[Rc[i32]]if nested bounds fail; - scoped-send positive for stack-bounded thread scope where allowed.
Add sema unit/spec tests for structural Send/Sync of tuples, arrays, and structs.
Acceptance criteria
Send,Sync, andScopedSendare all interned semantic language traits.- Compiler decisions use typed helpers, not only ephemerality or string checks.
- Channel/task/thread/generator boundaries enforce the correct trait.
- Diagnostics identify the non-Send/non-Sync source.
with build && with build :fixpoint && with build :testpass.
Dependencies
Depends on #391 and #470 for full useful coverage. Blocks #419 and #480 enforcement substance.
Traceability
From the requirements campaign (docs/requirements.md, spec v7.1). Affected requirement IDs: 14.16.1.10, 14.16.1.13, 14.16.1.2, 14.16.1.9, 14.20.1.10, 14.22.1.20, 14.22.1.4.
Activity
ehartford commentedon Jun 15, 2026
Implemented in
42a540d4.What changed:
SyncalongsideSendandScopedSendas language-level traits.Send/Sync/ScopedSendpredicates for primitives, references, structs, enums, generic instantiations,Box,Rc,Arc,Task, channels, and std containers.Rc[T]non-Send/non-Sync,Arc[T]conditional onT: Send + Sync, andBox[T]delegate toT.thread.spawn_os, and scoped thread workers.docs/requirements.md.Verification passed on pushed
main:build,fixpoint, full:test, and explicit:test-greenusing the project seed/release compiler path.Note: the separate
@TypeOf(generator_call())alias crash discovered while attempting direct generator-state coverage remains open as #589.