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
{{ message }}
Repository navigation
Match.type handlers receive the matched input twice #10873
Written by an AI agent (Amp) on behalf of @jasonkuhrt.
What version of Effect is running?
effect 4.1.5, the latest release, and main at 0d2bb4a. 4.0.0-rc.110 is not affected.
What steps can reproduce the bug?
Since 4.0.0-rc.111, a Match.type handler receives the matched input twice. A handler with an optional second parameter, such as parseInt and its radix, reads the input as that parameter.
This is what 4.0.0-rc.110 prints (npm install --save-exact [email protected]). Each handler gets the matched value alone, as the handler type declares: Match.when takes (_: WhenMatch<R, P>, ...args: Args) => Ret, and Args is [] for a Match.type matcher.
What do you see instead?
NaN 2 2
parseInt is called as parseInt("8", "8") and parses in base 8. Both the when handler and the orElse handler get two arguments.
Additional information
#7363 added Match.fn in 4.0.0-rc.111, and its description says it carries the selector's arguments "without changing Match.type or Match.value". Since then the terminals call each case as evaluate(input, ...args) and orElse calls its handler as f(failure, ...args), with the arguments the matcher was called with. A Match.type matcher's selector is identity, so that one argument is the input itself, and every handler gets (input, input). Match.value is not affected.
Activity