fix: respect defaultValue when arg is AstNodeType.EMPTY#1631
Open
marcin-kordas-hoc wants to merge 1 commit intodevelopfrom
Open
fix: respect defaultValue when arg is AstNodeType.EMPTY#1631marcin-kordas-hoc wants to merge 1 commit intodevelopfrom
marcin-kordas-hoc wants to merge 1 commit intodevelopfrom
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.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1631 +/- ##
========================================
Coverage 97.18% 97.18%
========================================
Files 172 172
Lines 14836 14841 +5
Branches 3258 3262 +4
========================================
+ Hits 14418 14423 +5
Misses 418 418
🚀 New features to boost your workflow:
|
Performance comparison of head (f68ecd8) vs base (4042b04) |
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 central interpreter argument-coercion logic, which can subtly change results for many functions when users pass empty trailing arguments.
Overview
Fixes function argument handling so an explicitly empty argument (parsed as
AstNodeType.EMPTYand evaluated toEmptyValue) now uses the parameter’s declareddefaultValueinstead of being coerced as a real value.This updates
FunctionPlugin.coerceArgumentsToRequiredTypesto substitutedefaultValuewhenrawArg === EmptyValue(and adefaultValueis defined), aligning behavior with omitted arguments across functions likeVLOOKUP/MATCH/LOGthat rely on non-zero defaults.Written by Cursor Bugbot for commit f68ecd8. This will update automatically on new commits. Configure here.