Description
When a user passes an empty argument to ADDRESS (e.g. =ADDRESS(1,1,) or =ADDRESS(1,1,1,)), the absNum and a1Style parameters should use their declared defaultValue (1 and true respectively). Instead, EmptyValue is coerced to 0/false, producing incorrect results.
Note: This applies only to ADDRESS. Excel 2021 and Google Sheets consistently treat empty arguments as the zero-value for the type (0 for numbers, FALSE for booleans) across all other functions — that is correct behavior, not a bug. ADDRESS is the confirmed exception.
| Function |
Parameter |
empty arg (Excel) |
omitted (Excel) |
HF bug? |
LOG |
base |
#NUM! (base=0) |
2 (base=10) |
No — HF matches Excel |
VLOOKUP |
sorted |
#N/A (exact match) |
"one" (sorted) |
No — HF matches Excel |
MATCH |
matchType |
#N/A (exact) |
1 (approx) |
No — HF matches Excel |
ADDRESS |
absNum |
"$A$1" (abs=1) |
"$A$1" (abs=1) |
Yes — HF gives 0 |
ADDRESS |
a1Style |
"$A$1" (a1=true) |
"$A$1" (a1=true) |
Yes — HF gives false |
Root cause
In FunctionPlugin.coerceArgumentsToRequiredTypes, the guard checks only for undefined when selecting the defaultValue. EmptyValue passes through and is coerced to 0/false.
Fix
Add an opt-in emptyAsDefault flag to FunctionArgument metadata. When set, EmptyValue is treated as omitted (uses defaultValue). Applied only to ADDRESS absNum and a1Style parameters.
Reproduction steps
const hf = HyperFormula.buildFromArray([
['=ADDRESS(1,1,)'], // empty absNum — should be "$A$1", bug: error or wrong format
['=ADDRESS(1,1,1,)'], // empty a1Style — should be "$A$1"
], { licenseKey: 'gpl-v3' })
HyperFormula version
3.2.0
Your framework
No response
Your environment
Node.js
Description
When a user passes an empty argument to
ADDRESS(e.g.=ADDRESS(1,1,)or=ADDRESS(1,1,1,)), theabsNumanda1Styleparameters should use their declareddefaultValue(1 andtruerespectively). Instead,EmptyValueis coerced to0/false, producing incorrect results.Note: This applies only to ADDRESS. Excel 2021 and Google Sheets consistently treat empty arguments as the zero-value for the type (
0for numbers,FALSEfor booleans) across all other functions — that is correct behavior, not a bug. ADDRESS is the confirmed exception.LOGbase#NUM!(base=0)2(base=10)VLOOKUPsorted#N/A(exact match)"one"(sorted)MATCHmatchType#N/A(exact)1(approx)ADDRESSabsNum"$A$1"(abs=1)"$A$1"(abs=1)0ADDRESSa1Style"$A$1"(a1=true)"$A$1"(a1=true)falseRoot cause
In
FunctionPlugin.coerceArgumentsToRequiredTypes, the guard checks only forundefinedwhen selecting thedefaultValue.EmptyValuepasses through and is coerced to0/false.Fix
Add an opt-in
emptyAsDefaultflag toFunctionArgumentmetadata. When set,EmptyValueis treated as omitted (usesdefaultValue). Applied only to ADDRESSabsNumanda1Styleparameters.Reproduction steps
HyperFormula version
3.2.0
Your framework
No response
Your environment
Node.js