Skip to content

fix(HF-268): support consecutive percent operators - #1773

Open
Tobiadefami wants to merge 2 commits into
developfrom
fix/HF-268
Open

Tobiadefami wants to merge 2 commits into
developfrom
fix/HF-268

Conversation

@Tobiadefami

@Tobiadefami Tobiadefami commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

Formulas such as =5%% failed to parse even though =(5%)% worked. Consume consecutive postfix percent operators and wrap the preceding expression for each token, so =5%% returns 0.0005 and =5%%% returns 0.000005, matching Excel.

Preserve each operator's whitespace and the existing operator precedence. Document the behavior in the operator guide and Unreleased changelog.

Validated with the matching fix/HF-268 test branch: 502 Jest suites and 6,254 tests passed, and Chrome and Firefox each passed 6,254 tests. Compilation and performance benchmarks passed. Full lint passed with zero errors and existing warnings using the test TypeScript project.

Context

How did you test your changes?

Types of changes

  • Breaking change (a fix or a feature because of which an existing functionality doesn't work as expected anymore)
  • New feature or improvement (a non-breaking change that adds functionality)
  • Bug fix (a non-breaking change that fixes an issue)
  • Additional language file, or a change to an existing language file (translations)
  • Change to the documentation

Related issues:

  1. Fixes #...

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.
  • 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
Localized parser grammar change for postfix % with existing AST builder; behavior aligns with Excel for previously failing formulas.

Overview
Fixes formula parsing so multiple postfix % operators chain on the same atomic expression, matching Excel (e.g. =5%%0.0005 instead of failing while =(5%)% worked).

The parser rule rightUnaryOpAtomicExpression now consumes zero or more % tokens and applies buildPercentOpAst repeatedly on the growing expression, preserving operator whitespace and precedence. Docs clarify that each % divides by 100, and the Unreleased changelog records the fix.

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

Formulas such as =5%% failed to parse even though =(5%)% worked.
Consume consecutive postfix percent operators and wrap the preceding
expression for each token, so =5%% returns 0.0005 and =5%%% returns
0.000005, matching Excel.

Preserve each operator's whitespace and the existing operator precedence.
Document the behavior in the operator guide and Unreleased changelog.

Validated with the matching fix/HF-268 test branch: 502 Jest suites and
6,254 tests passed, and Chrome and Firefox each passed 6,254 tests.
Compilation and performance benchmarks passed. Full lint passed with
zero errors and existing warnings using the test TypeScript project.
@cla-external-contractor-signup

Copy link
Copy Markdown

@Tobiadefami thanks for the pull request. No CLA step needed here — our records show you signed the Contributor License Agreement on 2026-07-31. That signature came from our previous signing form and has been carried over, so there is nothing for you to re-sign.

@qunabu

qunabu commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Task linked: HF-268 Promile operator (%%)

Add the pull request reference to the consecutive percent operators
changelog entry, matching the surrounding entries.

Validated the PR target and checked the Markdown diff for whitespace errors.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5361c44. Configure here.

Comment thread CHANGELOG.md Outdated
@codecov

codecov Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.32%. Comparing base (c920375) to head (56a15f1).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1773      +/-   ##
===========================================
- Coverage    97.32%   97.32%   -0.01%     
===========================================
  Files          195      195              
  Lines        15739    15738       -1     
  Branches      3390     3460      +70     
===========================================
- Hits         15318    15317       -1     
+ Misses         421      413       -8     
- Partials         0        8       +8     
Files with missing lines Coverage Δ
src/parser/FormulaParser.ts 97.37% <100.00%> (-0.01%) ⬇️

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Sep 14, 2026

Copy link
Copy Markdown

Performance comparison of head (5361c44) vs base (c920375)

                                     testName |    base |    head | change
--------------------------------------------------------------------------
                                      Sheet A |   508.5 |  506.77 | -0.34%
                                      Sheet B |  163.62 |  164.46 | +0.51%
                                      Sheet T |  144.86 |  144.85 | -0.01%
                                Column ranges |  481.33 |  486.04 | +0.98%
                                Sorted lookup | 14752.7 | 14501.3 | -1.70%
Sheet A:  change value, add/remove row/column |   16.59 |   16.52 | -0.42%
 Sheet B: change value, add/remove row/column |  149.13 |   143.2 | -3.98%
                   Column ranges - add column |  158.88 |  157.34 | -0.97%
                Column ranges - without batch |  485.82 |  487.93 | +0.43%
                        Column ranges - batch |   121.4 |  119.42 | -1.63%

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
hyperformula-docs 56a15f1 Commit Preview URL

Branch Preview URL
Sep 14 2026, 05:25 PM

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.

2 participants