Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#CYCLE! shouldn't occur when the IF condition is not met #336

Open
wojciechczerniak opened this issue May 4, 2020 · 6 comments
Open

#CYCLE! shouldn't occur when the IF condition is not met #336

wojciechczerniak opened this issue May 4, 2020 · 6 comments
Labels
To Be Discussed Extra attention is needed Verified Verified by Handsoncode

Comments

@wojciechczerniak
Copy link
Contributor

wojciechczerniak commented May 4, 2020

Description

If we have an IF function where the conditions that lead to #CYCLE! error isn't met we will get an error anyway. All other spreadsheets I've checked, GS, XL, LC, handles this situation differently. When the condition for circular reference is met the GS will show #REF with a description about circular reference, XL will display a pop-up, LC will show Err:522 which is described as "522 Circular reference"[1].

HF will always return #CYCLE! error. Doesn't matter if the condision is met or not.

Steps to reproduce

This test should pass

it('circular dependency when the IF condition is not met', () => {
  const engine = HyperFormula.buildFromArray([
    ['0', '=IF($A$1=0,0,B1)'],
    ['1', '=IF($A$2=0,0,B1)'],
  ])

  expect(engine.getCellValue(adr('B1'))).toEqual(0)
  expect(engine.getCellValue(adr('B1'))).toEqual(detailedError(ErrorType.CYCLE))
})

Links

[1] https://help.libreoffice.org/6.2/en-US/text/scalc/05/02140000.html

@wojciechczerniak wojciechczerniak added the Bug Something isn't working label May 4, 2020
@wojciechczerniak wojciechczerniak added this to the May 2020 milestone May 4, 2020
@wojciechczerniak wojciechczerniak changed the title #CIRCLE! shouldn't occur when the IF condision is not met #CIRCLE! shouldn't occur when the IF condition is not met May 4, 2020
@wojciechczerniak wojciechczerniak modified the milestones: May 2020, Next May 4, 2020
@wojciechczerniak wojciechczerniak added Evaluator To Be Discussed Extra attention is needed and removed Bug Something isn't working labels May 4, 2020
@wojciechczerniak
Copy link
Contributor Author

By design. ATM no plans to change the behavior, because it would affect the performance.

@bardek8
Copy link
Collaborator

bardek8 commented May 5, 2020

We should also remember, that this would require revision of the main assumptions of the design of HyperFormula. It seems possible, but we should expect a big change in the engine.

@krzysztofspilka krzysztofspilka added the Verified Verified by Handsoncode label Jun 23, 2020
@bardek8
Copy link
Collaborator

bardek8 commented Oct 7, 2020

Even simpler example presenting this issue:

it('circular dependency when the IF condition is not met', () => {
  const engine = HyperFormula.buildFromArray([
    ['5', '=IF(A1=0,B1,A1)'],
  ])

  expect(engine.getCellValue(adr('B1'))).toEqual(5)
})

as currently HF will return #CYCLE error for B1.

@doczoidberg
Copy link

doczoidberg commented Oct 8, 2020

I get the following results:

    this.hf.setCellContents({ sheet: this.mainDT, col: 0, row: 0 }, "=B1");
    this.hf.setCellContents({ sheet: this.mainDT, col: 1, row: 0 }, "=A1");
    this.hf.setCellContents({ sheet: this.mainDT, col: 2, row: 0 }, "=IF(FALSE,1,A1)"); 
    this.printCellData("C1", this.mainDT);// cycle
    this.hf.setCellContents({ sheet: this.mainDT, col: 2, row: 0 }, "=IF(TRUE,1,A1)"); 
    this.printCellData("C1", this.mainDT);// no cycle

so it works as in excel?

@bardek8
Copy link
Collaborator

bardek8 commented Oct 8, 2020

Yes, this works. But the problem is when the IF cell depends on different cells depending on the evaluation of the expression and only one of them leads to the cycle. Then we always return the cycle, no matter what is the value of the logical expression.
Please see the examples above.

@wojciechczerniak wojciechczerniak removed this from the Next milestone Feb 1, 2021
@sequba sequba changed the title #CIRCLE! shouldn't occur when the IF condition is not met #CYCLE! shouldn't occur when the IF condition is not met Feb 10, 2022
@sequba sequba removed the Evaluator label Apr 15, 2022
@thilgen
Copy link
Contributor

thilgen commented Apr 4, 2023

Related: #1214

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
To Be Discussed Extra attention is needed Verified Verified by Handsoncode
Projects
None yet
Development

No branches or pull requests

6 participants