Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
- Fixed a problem with dependencies not collected for specific functions. (#550, #549)
- Fixed a minor problem with dependencies under nested parenthesis. (#549, #558)

## [0.3.0] - 2020-10-22

Expand Down
10 changes: 7 additions & 3 deletions src/interpreter/plugin/FunctionPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@

import {AbsoluteCellRange} from '../../AbsoluteCellRange'
import {CellError, ErrorType, InternalScalarValue, SimpleCellAddress} from '../../Cell'
import {SearchStrategy} from '../../Lookup/SearchStrategy'
import {Config} from '../../Config'
import {DependencyGraph} from '../../DependencyGraph'
import {ErrorMessage} from '../../error-message'
import {SearchStrategy} from '../../Lookup/SearchStrategy'
import {Maybe} from '../../Maybe'
import {Ast, AstNodeType, ProcedureAst} from '../../parser'
import {Serialization} from '../../Serialization'
import {coerceScalarToBoolean, coerceScalarToString, coerceToRange} from '../ArithmeticHelper'
import {Interpreter} from '../Interpreter'
import {InterpreterValue, SimpleRangeValue} from '../InterpreterValue'
import {Serialization} from '../../Serialization'

export interface ImplementedFunctions {
[formulaId: string]: FunctionMetadata,
Expand Down Expand Up @@ -294,7 +294,11 @@ export abstract class FunctionPlugin {
} else if (args.length > 1) {
return new CellError(ErrorType.NA, ErrorMessage.WrongArgNumber)
}
const arg = args[0]
let arg = args[0]

while(arg.type === AstNodeType.PARENTHESIS) {
arg = arg.expression
}

let cellReference: Maybe<SimpleCellAddress>

Expand Down
2 changes: 1 addition & 1 deletion src/parser/collectDependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const collectDependenciesFn = (ast: Ast, functionRegistry: FunctionRegistry, dep
collectDependenciesFn(ast.right, functionRegistry, dependenciesSet, true)
return
case AstNodeType.PARENTHESIS:
collectDependenciesFn(ast.expression, functionRegistry, dependenciesSet, false)
collectDependenciesFn(ast.expression, functionRegistry, dependenciesSet, needArgument)
return
case AstNodeType.FUNCTION_CALL: {
const functionNeedArgument = !functionRegistry.doesFunctionNeedArgumentToBeComputed(ast.procedureName)
Expand Down
21 changes: 21 additions & 0 deletions test/interpreter/paren-deps.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {HyperFormula} from '../../src'
import {adr} from '../testUtils'

describe('dependencies with parenthesis', () => {
it('should be collected when required', () => {
const engine = HyperFormula.buildFromArray([
['=SUM(1)'],
['=(A1)+((A3))'],
['=SUM(1)'],
])
expect(engine.getCellValue(adr('A2'))).toEqual(2)
})

it('should not build ref for special function', () => {
const engine = HyperFormula.buildFromArray([
['=COLUMN((((A1))))']
])

expect(engine.getCellValue(adr('A1'))).toEqual(1)
})
})