Skip to content

structurallyEqual

structurallyEqual(left, right, context): boolean

structurallyEqual reports whether two expressions are structural duplicates: the same node kind, checked type, and resolved reference, with the same children in the same order. It ignores expression ids, source offsets, and other formatting metadata, since two nodes built from different source positions can still be the same expression.

Structural duplication is narrower than logical equivalence: this function finds safe-to-drop duplicates, not proof that two differently-shaped expressions always produce the same value. When it cannot establish equality from the available metadata, it treats the expressions as distinct. A missed duplicate only costs a slightly larger result; a wrongly-merged pair would silently change behavior.

Expr

Expr

StructuralEqualityContext

boolean