Skip to content

Commit 718417e

Browse files
IvanHristov98Ivan Hristov
and
Ivan Hristov
authored
This closes qax-os#2083, fix subexpression calculation (qax-os#2084)
Co-authored-by: Ivan Hristov <[email protected]>
1 parent 05ed940 commit 718417e

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

calc.go

+1-8
Original file line numberDiff line numberDiff line change
@@ -1008,13 +1008,6 @@ func (f *File) evalInfixExp(ctx *calcContext, sheet, cell string, tokens []efp.T
10081008
}
10091009
}
10101010

1011-
if isEndParenthesesToken(token) && isBeginParenthesesToken(opftStack.Peek().(efp.Token)) {
1012-
if arg := argsStack.Peek().(*list.List).Back(); arg != nil {
1013-
opfdStack.Push(arg.Value.(formulaArg))
1014-
argsStack.Peek().(*list.List).Remove(arg)
1015-
}
1016-
}
1017-
10181011
// check current token is opft
10191012
if err = f.parseToken(ctx, sheet, token, opfdStack, opftStack); err != nil {
10201013
return newEmptyFormulaArg(), err
@@ -1085,7 +1078,7 @@ func (f *File) evalInfixExpFunc(ctx *calcContext, sheet, cell string, token, nex
10851078
opftStack.Pop() // remove current function separator
10861079
opfStack.Pop()
10871080
if opfStack.Len() > 0 { // still in function stack
1088-
if nextToken.TType == efp.TokenTypeOperatorInfix || (opftStack.Len() > 1 && opfdStack.Len() > 0) {
1081+
if nextToken.TType == efp.TokenTypeOperatorInfix || opftStack.Len() > 1 {
10891082
// mathematics calculate in formula function
10901083
opfdStack.Push(arg)
10911084
return newEmptyFormulaArg()

calc_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,9 @@ func TestCalcCellValue(t *testing.T) {
895895
"=1+SUM(SUM(1,2*3),4)*4/3+5+(4+2)*3": "38.6666666666667",
896896
"=SUM(1+ROW())": "2",
897897
"=SUM((SUM(2))+1)": "3",
898+
"=IF(2<0, 1, (4))": "4",
899+
"=IF(2>0, (1), 4)": "1",
900+
"=IF(2>0, (A1)*2.5, 4)": "2.5",
898901
"=SUM({1,2,3,4,\"\"})": "10",
899902
// SUMIF
900903
"=SUMIF(F1:F5, \"\")": "0",

0 commit comments

Comments
 (0)