script: a callback's one-item reply re-enters the multiplexer, and :else acts on its value - #412
Merged
Merged
Conversation
…lse acts on its value A callback's reply was measured after being replaced by the text it sent, so ['abc'] counted as three items and left the multiplexer. :else threw away its value's result, so :else: :redo stopped listening, and :else: null never fired at all: it polled the fast timeout forever. Both now behave as a static reply and any other key's value do.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three multiplexer bugs in
packages/script, each confirmed with a pin that fails without the fix.dispatchValsent the reply, then checkedback.length, which by then was the sent string. So-> ['abc']counted as three items and left the multiplexer, while the same['abc']written in the table re-entered it (and-> ['a']worked only because one character has length 1). The:pureform had the same flaw. The check now measures the reply list, as the static branch does.:elsethrew away its value's result. The branch setback = :elseand discarded whatdispatchValreturned, so:else: :redoended the multiplexer at the first pause instead of listening on. It now takes the result like any other key.:else: nullnever fired. The branch was guarded byelseVal?, buthasElsestill put every read on thefasttimeout, so the multiplexer polled every 0.25 s forever and never reachedsloworbomb. The guard is nowhasElse, andnullleaves the multiplexer, as the README's own:else: nullexample assumes.All three now match the engine's Ruby ancestor, which measured the reply array and assigned the
:elsevalue's result.One visible change: when
:elsefires, the multiplexer returns its handler's value rather than the:elsesymbol (a string:elsevalue, as inreplace(), still returns:else). The existing:else firestest now expects its handler'strue. The README's:elserow says what the value does.Verification:
bun run testinpackages/script, 66 passed (63 before; the three new pins fail or hang without the fix). The old and new engines give identical transcripts and results on seven unchanged cases (multi-step callback replies,[text, :redo]and[:pure, text, :redo], callbacks returningtrue/:redo, static replies,:this, a string:else). em's full MVTS run driven by the fixed engine: 4,238 PASS, 0 FAIL, as before.