You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The previous when cascade used the pattern
REGEX.find(line)?.let { ...; null } != null -> return ...
which always evaluated to false on both arms (the let returned null on
match, and short-circuited to null on no-match), making the right-side
return dead code. Every matching regex's let body ran and the function
fell through to the trailing blocks, destroying the first-match-wins
precedence the original parseScanLine early-returns guaranteed. Test
case 13 (scanTotalsPreemptsActiveResolversOnSameLine) would have
observed activeResolvers=5 instead of the expected 0.
Rewrite using the idiomatic Option A shape: pre-compute the 6 early-return
match results (scanMatch, activeMatch, totalActiveMatch, remainingMatch,
syncedMtuMatch, testingMtu) before the when, let the when mutate
scanStatus for the first matching arm only, then a single
if (anyMatched) return short-circuits the trailing MTU-completed /
Session-initialized / SESSION_INIT_BACKOFF blocks. The 4 non-returning
pre blocks (RESOLVER_ADDED, RESOLVER_REMOVED, INDEXED_PROGRESS,
TOTAL_CANDIDATES) stay before the cascade, unchanged. Hand-traced cases
9, 10, 12, 13 line-by-line against the original parseScanLine; all
produce identical state.
0 commit comments