V3001 There are identical sub-expressions ‘u.TypeArguments.Length’ to the left and to the right of the ‘!=’ operator. generic.cs 3135

public int ExactInference (TypeSpec u, TypeSpec v)
  var ac_u = (ArrayContainer) u;
  var ac_v = (ArrayContainer) v;
  var ga_u = u.TypeArguments;
  var ga_v = v.TypeArguments;
  if (u.TypeArguments.Length != u.TypeArguments.Length) 
    return 0;


Now, when the method code can not be simplified, it won’t be hard to notice an error in the if statement – the parameter v, not u, should be used as an instance of the TypeSpec type. Perhaps the error was due to the fact that the characters u and v look quite the similar, and it’s easy to confuse them if the person isn’t focused on this expression.

The rest of the code was given to underline that these parameters are usually used together,

if (u.TypeArguments.Length != v.TypeArguments.Length) 
    return 0;

Please click here to see more bugs from this project.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.