fix: respect defaultValue when arg is AstNodeType.EMPTY#1630
Closed
marcin-kordas-hoc wants to merge 1 commit intohandsontable:developfrom
Closed
fix: respect defaultValue when arg is AstNodeType.EMPTY#1630marcin-kordas-hoc wants to merge 1 commit intohandsontable:developfrom
marcin-kordas-hoc wants to merge 1 commit intohandsontable:developfrom
Conversation
When a user writes an empty argument (e.g. =FUNC(a,,c)), the parser produces AstNodeType.EMPTY which evaluates to EmptyValue (a Symbol sentinel, not undefined). The previous guard passed EmptyValue through, bypassing the declared defaultValue and coercing it to 0 or false instead. Fix: treat EmptyValue as absent only when the parameter declares an explicit defaultValue, so functions like LOG, VLOOKUP, MATCH etc. get their correct defaults.
Collaborator
Author
|
Wrong origin |
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.
Problem
When a user writes an empty argument (e.g.
=VLOOKUP(2,A1:B3,2,)), the parserproduces
AstNodeType.EMPTYwhich evaluates toEmptyValue(a Symbol sentinel).The guard in
FunctionPlugin.coerceArgumentsToRequiredTypeschecked only forundefined, soEmptyValuepassed through and was coerced to0/falseinsteadof using the parameter's declared
defaultValue.Affected functions: any plugin parameter with
defaultValue ≠ 0/false(e.g.
LOGbase=10,VLOOKUP/HLOOKUPsorted=true,MATCHmatchType=1,ADDRESSabs=1).Fix
In
FunctionPlugin.coerceArgumentsToRequiredTypes: when the runtime value isEmptyValueand the parameter declares an explicitdefaultValue, substitutedefaultValueinstead of passingEmptyValueto type coercion.Tests
Regression tests in companion PR in
handsontable/hyperformula-tests(branch
fix/empty-default-value): covers VLOOKUP, HLOOKUP, MATCH, ADDRESS, LOG.Note
Medium Risk
Touches shared function-argument coercion used by all formula plugins, so behavior changes may surface broadly, but the change is narrow and gated to
EmptyValuewith an explicitdefaultValue.Overview
Fixes argument coercion so explicitly empty arguments (parsed as
AstNodeType.EMPTY→EmptyValue) are treated like “missing” when a parameter defines adefaultValue.In
FunctionPlugin.coerceArgumentsToRequiredTypes,EmptyValuenow substitutes the correspondingdefaultValue(when provided) before type coercion, preventing empty trailing args from being coerced into0/falsefor functions likeLOG,VLOOKUP/HLOOKUP,MATCH, andADDRESS.Written by Cursor Bugbot for commit f68ecd8. This will update automatically on new commits. Configure here.