fix(events): a listener's return ends that listener, not the dispatch
Listeners are compiled into one @ev_<E> function and return branched to its exit, so every listener declared after one that returned early - and every foreign listener - never heard the event. The per-kind listener shape (return unless it is my kind) answered only the first-declared kind. examples/events/answer.ludic holds it; seed regenerated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
45e14dbb99
commit
f5ab5cf88a
8 changed files with 11240 additions and 11128 deletions
|
|
@ -652,7 +652,18 @@ function emit_event_fns() -> void {
|
|||
let base = nloc # listeners share the params but not each other's locals
|
||||
var i = 0
|
||||
while i < len(g_onlisten) {
|
||||
if (g_onlisten[i].s == en) { nloc = base; g_term = false; emit_block(g_onlisten[i].a) }
|
||||
if (g_onlisten[i].s == en) {
|
||||
# a `return` ends this listener, not the dispatch: the next one and the foreign ones still run
|
||||
nloc = base
|
||||
g_term = false
|
||||
let next = lbl("evnext")
|
||||
g_ret_label = next
|
||||
emit_block(g_onlisten[i].a)
|
||||
g_ret_label = "ret"
|
||||
if not g_term { emit(` br label %{next}\n`) }
|
||||
emit(`{next}:\n`)
|
||||
g_term = false
|
||||
}
|
||||
i += 1
|
||||
}
|
||||
# the open half: walk the foreign callback array in registration order
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue