Our website uses cookies to enhance your browsing experience.
Accept
to the top
>
>
>
V8027. Suspicious subexpression in a...
menu mobile close menu
Additional information
toggle menu Contents

V8027. Suspicious subexpression in a sequence of similar comparisons.

Jun 10 2026

The analyzer has detected a code fragment that most likely contains a typo. A chain of similar structure member comparisons contains an expression that differs from the others. It compares members with different names, while the rest of the chain compares members with the same name.

The example:

func foo(a TestStruct, b TestStruct) interface{} {
  if a.x == b.x && a.y == b.y && a.z == b.y {
    ....
  }
}

In this case, the a.z == b.y expression differs from the other elements in the chain. The error most likely occurred due to a typo made while editing the copied text.

The fixed code:

func foo(a TestStruct, b TestStruct) interface{} {
  if a.x == b.x && a.y == b.y && a.z == b.z {
    ....
  }
}

The analyzer issues a warning whenever the comparison chain has more than two expressions.