Skip to content

Related to #1164: fix incorrect argument count with nested func in parenthesized sub-exporessions - #2348

Merged
xuri merged 2 commits into
qax-os:masterfrom
Aprax14:fix-nested-func-arg-count
Jul 14, 2026
Merged

Related to #1164: fix incorrect argument count with nested func in parenthesized sub-exporessions#2348
xuri merged 2 commits into
qax-os:masterfrom
Aprax14:fix-nested-func-arg-count

Conversation

@Aprax14

@Aprax14 Aprax14 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Description

When a function argument contains an expression like 1+(ABS(A1)+A1)/2, the formula parser in prepareEvalInfixExp miscounts the outer function's arguments (e.g. IF or SUM), throwing errors like "IF accepts at most 3 arguments".

Root cause: when an inner function closes, the code checks whether the operand on opfdStack belongs to the current function or an outer expression by looking at the token directly below on opftStack. If a subexpression-start token "(" or another function-start token (e.g. SUM) sits between the function marker and the actual infix operator (e.g. +), this check fails and the operand gets wrongly consumed as a function argument.

Related Issue

#1164

Motivation and Context

The added unit tests would fail without this fix while they are valid in MS Excel.

How Has This Been Tested

Added unit tests

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.62%. Comparing base (90ff348) to head (bab8b27).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2348   +/-   ##
=======================================
  Coverage   99.62%   99.62%           
=======================================
  Files          32       32           
  Lines       26961    26969    +8     
=======================================
+ Hits        26859    26867    +8     
  Misses         53       53           
  Partials       49       49           
Flag Coverage Δ
unittests 99.62% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@xuri xuri added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jul 10, 2026
@xuri xuri added this to v2.11.1 Jul 14, 2026
@xuri xuri moved this to Bugfix in v2.11.1 Jul 14, 2026
Comment thread calc.go Outdated

@xuri xuri left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! I've made some changes based on your code branch.

@xuri
xuri merged commit 1a6d13b into qax-os:master Jul 14, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

Status: Bugfix

Development

Successfully merging this pull request may close these issues.

2 participants