Skip to content

Commit fed235c

Browse files
committed
Simple mutation prototype that crashes Sieve
1 parent 8ef0e57 commit fed235c

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/benchmark/Sieve.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class Filter extends Reactor {
9090
} else {
9191
// Potential prime found.
9292
if (!hasChild.get()) {
93-
const n = new Filter(this.getReactor(), p, numberOfPrimes);
93+
const n = this.getReactor()._uncheckedAddSibling(Filter, p, numberOfPrimes);
9494
// this.start(n)
9595
// console.log("CREATING...")
9696
// let x = this.create(Filter, [this.getReactor(), p])

src/core/reactor.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,6 +1555,27 @@ export abstract class Reactor extends Component {
15551555
toString(): string {
15561556
return this._getFullyQualifiedName();
15571557
}
1558+
1559+
public _uncheckedAddChild<R extends Reactor, G extends unknown[]>(
1560+
constructor:new (container: Reactor, ...args: G) => R,
1561+
...args: G
1562+
): R {
1563+
const newReactor = new constructor(this, ...args);
1564+
return newReactor;
1565+
}
1566+
1567+
public _uncheckedAddSibling<R extends Reactor, G extends unknown[]>(
1568+
constructor:new (container: Reactor, ...args: G) => R,
1569+
...args: G
1570+
): R {
1571+
if (this._getContainer() == null) {
1572+
throw new Error(`Reactor ${this} does not have a parent. Sibling is not well-defined.`);
1573+
}
1574+
if (this._getContainer() === this) {
1575+
throw new Error(`Reactor ${this} is self-contained. Adding sibling creates logical issue.`);
1576+
}
1577+
return this._getContainer()._uncheckedAddChild(constructor, ...args);
1578+
}
15581579
}
15591580

15601581
/*

0 commit comments

Comments
 (0)