Ignore spurious differences in job patterns

This commit is contained in:
Tony Garnock-Jones 2018-12-14 13:27:19 +00:00
parent bbbc1cc0a0
commit b85ba4a9f0
2 changed files with 17 additions and 2 deletions

View File

@ -460,6 +460,19 @@ function isCompletelyConcrete(p) {
return walk(p);
}
function withoutCaptures(p) {
function walk(p) {
if (Capture.isClassOf(p)) return walk(p.get(0));
if (Discard.isClassOf(p)) return p;
const cls = classOf(p);
if (cls === null) return p;
if (typeof cls === 'number') return p.map(walk);
return new Record(p.label, p.fields.map(walk));
}
return walk(p);
}
///////////////////////////////////////////////////////////////////////////
module.exports.EVENT_ADDED = EVENT_ADDED;
@ -471,3 +484,4 @@ module.exports.analyzeAssertion = analyzeAssertion;
module.exports.instantiateAssertion = instantiateAssertion;
module.exports.match = match;
module.exports.isCompletelyConcrete = isCompletelyConcrete;
module.exports.withoutCaptures = withoutCaptures;

View File

@ -17,8 +17,9 @@ spawn named 'JobDispatcher' {
during Observe(Observe(WorkItem($worker, $pattern, _))) {
if (!Skeleton.isCompletelyConcrete(pattern)) {
on start addWorker(pattern, worker);
on stop removeWorker(pattern, worker);
const p = Skeleton.withoutCaptures(pattern);
on start addWorker(p, worker);
on stop removeWorker(p, worker);
}
}