Skip to content

Fix IFS short-circuit evaluation#1676

Open
JfanLiu wants to merge 2 commits into
handsontable:developfrom
JfanLiu:fix/ifs-short-circuit
Open

Fix IFS short-circuit evaluation#1676
JfanLiu wants to merge 2 commits into
handsontable:developfrom
JfanLiu:fix/ifs-short-circuit

Conversation

@JfanLiu
Copy link
Copy Markdown

@JfanLiu JfanLiu commented May 20, 2026

Context

IFS should stop evaluating condition/value pairs once it finds the first true condition. This matches Microsoft Excel and Google Sheets behavior.

For example, Excel returns 1 for:

=IFS(TRUE(), 1, 1/0, 2)

HyperFormula previously evaluated later arguments and returned an error.

How did you test your changes?

  • Added a smoke regression test for =IFS(TRUE(), 1, 1/0, 2).
  • Ran npm run test:jest -- smoke.
  • Ran npm run verify:typings.
  • Ran npm run lint.

Related issues:

N/A

Checklist:

  • I have reviewed the guidelines about Contributing to HyperFormula and I confirm that my code follows the code style of this project.
  • I have signed the Contributor License Agreement.
  • My change is compliant with the OpenDocument standard. N/A: OpenFormula 1.3 does not define IFS.
  • My change is compatible with Microsoft Excel.
  • My change is compatible with Google Sheets.
  • I described my changes in the CHANGELOG.md file.
  • My changes require a documentation update.
  • My changes require a migration guide.

Note

Low Risk
Low risk: changes are localized to IFS evaluation logic and add a regression test; main risk is subtle behavior differences in array arithmetic/vectorized cases.

Overview
Fixes IFS to short-circuit evaluation: condition/value pairs are now evaluated sequentially and stop once the first true condition is found, avoiding errors from later branches (e.g. 1/0).

Keeps the prior vectorized implementation for array arithmetic by falling back to runFunction when array/range arguments are detected, and adds a smoke regression test plus a CHANGELOG entry documenting the fix.

Reviewed by Cursor Bugbot for commit c8987fa. Bugbot is set up for automated code reviews on this repo. Configure here.

Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 20, 2026

Deploy Preview for hyperformula-docs ready!

Name Link
🔨 Latest commit c8987fa
🔍 Latest deploy log https://app.netlify.com/projects/hyperformula-docs/deploys/6a0dbf699e0fd40008ea196e
😎 Deploy Preview https://deploy-preview-1676--hyperformula-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 20, 2026

Deploy Preview for hyperformula-dev-docs ready!

Name Link
🔨 Latest commit c8987fa
🔍 Latest deploy log https://app.netlify.com/projects/hyperformula-dev-docs/deploys/6a0dbf6923f6850008e98987
😎 Deploy Preview https://deploy-preview-1676--hyperformula-dev-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@JfanLiu JfanLiu force-pushed the fix/ifs-short-circuit branch from 70cc0ba to c8987fa Compare May 20, 2026 14:04
@JfanLiu JfanLiu changed the title Fix/ifs short circuit Fix IFS short-circuit evaluation May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant