fix(#1632): narrow empty arg defaultValue to ADDRESS only#1631
Open
marcin-kordas-hoc wants to merge 2 commits intodevelopfrom
Open
fix(#1632): narrow empty arg defaultValue to ADDRESS only#1631marcin-kordas-hoc wants to merge 2 commits intodevelopfrom
marcin-kordas-hoc wants to merge 2 commits 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.
Performance comparison of head (f09a219) vs base (4042b04) |
…ault) Excel treats empty args as zero-value for the type (0/FALSE/"") for all functions. ADDRESS is the only confirmed exception where empty args use the declared defaultValue. Add opt-in emptyAsDefault flag to FunctionArgument and apply it only to ADDRESS absNum and a1Style parameters. Verified against Excel 2021 and Google Sheets for LOG, VLOOKUP, MATCH, HLOOKUP, FIND, SUBSTITUTE, and ADDRESS.
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:
|
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
=ADDRESS(1,1,)or=ADDRESS(1,1,1,), the empty argumentis coerced to
0/falseinstead of using the parameter's declareddefaultValue.Excel 2021 and Google Sheets treat empty args as the zero-value for the type
(
0/FALSE) for all functions except ADDRESS, where emptyabsNumanda1Styleuse their declared defaults (1 andtrue).Fixes #1632
Fix
emptyAsDefaultopt-in flag toFunctionArgumentinterfacecoerceArgumentsToRequiredTypes: whenrawArg === EmptyValueANDemptyAsDefaultis set ANDdefaultValueis declared → substitutedefaultValueemptyAsDefault: trueonly to ADDRESSabsNumanda1StyleparametersTests
Regression tests in
handsontable/hyperformula-tests(branchfix/empty-default-value):absNum, emptya1Style, both emptyoptional-parameters.spec.ts: confirms empty args use zero-value coercion (not defaultValue) whenemptyAsDefaultis not setNote
Medium Risk
Touches the core argument-coercion path in
FunctionPlugin, so any function that opts intoemptyAsDefaultcould change behavior; impact is otherwise scoped to parameters explicitly marked with the new flag.Overview
Updates function-argument coercion to optionally treat an explicitly empty argument (
EmptyValue, e.g. trailing comma) as missing and substitute the parameter’sdefaultValueinstead of coercing the empty value to0/false.Adds a new
FunctionArgument.emptyAsDefaultmetadata flag to opt into this behavior, and enables it forADDRESS’sabsanduseA1Styleoptional parameters soADDRESS(…, , )uses the declared defaults.Written by Cursor Bugbot for commit f09a219. This will update automatically on new commits. Configure here.