this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Revert "internal/core/adt: remove now-unnecessary panic workaround"

This reverts https://cuelang.org/cl/1212273.
The added test case still causes a panic without the workaround.

We revert before we attempt a cleanup or better fix again,
because we intend to backport this safe fix to v0.16.

Fixes #4339.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: Iec7380dc2982c4a8b8f56249ef51337a1536b2ba
Reviewed-on: https://cue.gerrithub.io/c/cue-lang/cue/+/1236175
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Marcel van Lohuizen <mpvl@gmail.com>

+41
+30
cue/testdata/disjunctions/issue4339.txtar
··· 1 + # Tests that a default disjunct which embeds a struct referencing a sibling 2 + # field, combined with an if-comprehension gated on a default boolean, does 3 + # not panic. See: https://cuelang.org/issue/4339 4 + -- in.cue -- 5 + _withExtra: extra: out.one 6 + 7 + out: { 8 + *_withExtra | {} 9 + 10 + one: 1 11 + 12 + enable: *true | false 13 + if enable {} 14 + } @test(eq, 15 + // TODO: we should be able to use @test(final) here, avoiding the defaults. 16 + *{one: 1, enable: *true | false, extra: 1} | {one: 1, enable: *true | false}, 17 + ) 18 + -- out/compile -- 19 + --- in.cue 20 + { 21 + _withExtra: { 22 + extra: 〈1;out〉.one 23 + } 24 + out: { 25 + (*〈1;_withExtra〉|{}) 26 + one: 1 27 + enable: (*true|false) 28 + if 〈0;enable〉 {} 29 + } 30 + }
+11
internal/core/adt/sched.go
··· 293 293 } 294 294 295 295 func (s *scheduler) clear() { 296 + // Any tasks blocked on this scheduler are unblocked once the scheduler is cleared. 297 + // Otherwise they might signal a cleared scheduler, which can panic. 298 + // 299 + // TODO(mvdan,mpvl): In principle, all blocks should have been removed when a scheduler 300 + // is cleared. Perhaps this can happen when the scheduler is stopped prematurely. 301 + // For now, this solution seems to work OK. 302 + for _, t := range s.blocking { 303 + t.blockedOn = nil 304 + t.blockCondition = neverKnown 305 + } 306 + 296 307 // Free tasks back to the pool for reuse. Tasks are not cleared here because 297 308 // they may still be referenced in other schedulers' blocking queues. 298 309 // They will be cleared when obtained from the pool for reuse.