Class SharedStateMutationOutsideLockOrError
- All Implemented Interfaces:
Consumer<EK9Parser.AssignmentStatementContext>
CONCURRENT_ENTRY_POINT must occur inside
a MutexLock.enter(...) callback.
"Shared state" in this foundation pass means a field of the enclosing aggregate
โ a write to this.<field> (or the bare-identifier shorthand) from inside
a Component method, dynamic-class method, or other method that is transitively
reachable from an HTTP service operation, TCP/Signals handler, or async stream
stage. Subsequent passes will widen the rule to non-pure calls on shared
receivers and capture-write through closures.
Exemptions:
- MutexKey body โ the lambda passed to
enter()/tryEnter(). Writes here are by definition inside the lock. - Constructor body โ never carries the marker (Step 6/6b skip constructors). The object hasn't escaped yet so its fields aren't shared; E08250 forbids early publication.
A local that refers to shared state (counter <- shared.total) is that state under another
name: recordReference(ReferenceAssignment) marks it (REFERS_TO_SHARED_STATE, followed through further
locals), an in-place mutation of it (counter += 1, counter :=: 5) or a write to a
field through it is a write to shared state. Re-pointing the local (counter := 5) is not.
Every in-place mutation is seen, whatever statement applies it: an assignment's in-place operators
(+= -= *= /= :=: :^: :~:), the separate x++ / x-- statement, and the |
a stream termination or tee in applies to its target (mutatedInPlaceOrError(ISymbol, Token)).
A target whose type is Stdout or Stderr is exempt (isStandardOutput(ISymbol)).
Part of EK9's compile-time data-race detection (slice 1, model rule ยง3.5).
Error E08251 SHARED_STATE_MUTATION_OUTSIDE_LOCK.
-
Field Summary
Fields inherited from class RuleSupport
errorListener, symbolsAndScopes -
Constructor Summary
ConstructorsConstructorDescriptionSharedStateMutationOutsideLockOrError(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener) -
Method Summary
Modifier and TypeMethodDescriptionvoid(package private) voidThe statementx++/x--: a separate grammar alternative from an assignment, but the same in-place mutation asx += 1(Integer._incmutates the object, it stores nothing).(package private) voidThe target of a stream termination (> target,>> target) or of atee in target: each item is piped in with the target's|operator, which mutates the target in place.(package private) voidrecordReference(ReferenceAssignment reference) Mark a local that a declaration or assignment makes refer to shared state - a field of the enclosing aggregate, a capture, 'this', or a local already marked - directly or through a chain of field accesses.Methods inherited from class TypedSymbolAccess
emitTypeNotResolvedError, getRecordedAndTypedSymbol, isProcessingScopePure, recordATypedSymbol
-
Constructor Details
-
SharedStateMutationOutsideLockOrError
SharedStateMutationOutsideLockOrError(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener)
-
-
Method Details
-
accept
- Specified by:
acceptin interfaceConsumer<EK9Parser.AssignmentStatementContext>
-
acceptIncrementOrDecrement
The statementx++/x--: a separate grammar alternative from an assignment, but the same in-place mutation asx += 1(Integer._incmutates the object, it stores nothing). -
acceptStreamTarget
The target of a stream termination (> target,>> target) or of atee in target: each item is piped in with the target's|operator, which mutates the target in place. -
recordReference
Mark a local that a declaration or assignment makes refer to shared state - a field of the enclosing aggregate, a capture, 'this', or a local already marked - directly or through a chain of field accesses. A chain ending in a call is not followed (the call may return a fresh value).
-