Commit 02d79dc1
02d79dc13e12Merged
Ori Pekelman <[email protected]> · 5 months ago · 2 files · ~2 modified
Description
Ractor: reject @@cvar / $gvar access inside a Ractor (Ractor::IsolationError)
CRuby raises on cross-Ractor class-variable / global access; we now reject it at compile time instead of silently giving a child Ractor an empty (__thread) copy. emit_ractor_new recursively scans the body (including nested blocks) for ClassVariable* nodes (always rejected) and GlobalVariable* nodes that resolve to a user-declared global (rejected); thread-local / read-only specials ($~, $stdout, regex/status globals — not user-declared) are allowed. Non-Ractor cvar/gvar use is unchanged.
Full suite 931 pass / 0 fail / 0 error.
Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]
Details
- Commit
- 02d79dc13e12
- Parent
- 5c35304691ba
docs/RACTOR-RFC.mdmodifiedView file
spawn arguments.2. **FIFO mailbox / outgoing queue** (mutex + condvar, grows on demand), so a Ractor may `receive` several messages and a sender need not block per slot.3. **`@@cvars` / `$globals` are `__thread`** → isolated per Ractor, rather than CRuby's "shared, raise on cross-Ractor mutation". Simpler and safe, but a real semantic difference: a class-body cvar initializer has not run in a child Ractor unless re-executed there. Programs that rely on cross-Ractor cvar/gvar sharing are out of scope for this milestone.3. **`@@cvars` / `$globals` accessed inside a Ractor are rejected at compile time** with `Ractor::IsolationError`, mirroring CRuby (which raises on cross-Ractor class-variable / global access). Special, thread-local or read-only globals (`$~`, `$stdout`, regex/status specials — not user-declared) are allowed. The globals themselves remain `__thread` in the runtime; the compile-time check just prevents the silent-empty-value footgun.4. **`Ractor#send` with a bare String/Symbol *literal*** is parsed as a reflective send (`recv.send("m")` → `recv.m`, a whole-program parser behaviour), so send messages via `r << v` or a local (`r.send(v)`); literalssrc/codegen.cmodifiedView file
Loading diff…