HomeDelphiDelphi Error – E2603 Constraint ‘%s’ cannot be specified more than once

Delphi Error – E2603 Constraint ‘%s’ cannot be specified more than once

Delphi Compiler Error

E2603 Constraint ‘%s’ cannot be specified more than once

Reason for the Error & Solution

This occurs whenever you try to specify a generics constraint more than once.

type
  TFoo<T: constructor, constructor> = class // issues error: E2603 'constructor'
  end;
  TBar<T: class, class> = class             // issues error: E2603 'class'
  end;
  TBaz<T: record, record> = class           // issues error: E2603 'record'
  end;
end.

This can be solved by removing the extra constraint:

type
  TFooOK<T: constructor> = class // OK
  end;
  TBarOK<T: class> = class       // OK
  end;
  TBazOK<T: record> = class      // OK
  end;
end.

See Also

Share:

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

Delphi Compiler Error X2421 Imported identifier ‘%s’ conflicts with ‘%s’ in ‘%s’ Reason for the Error & Solution This occurs...
Delphi Compiler Error X2367 Case of property accessor method %s.%s should be %s.%s Reason for the Error & Solution No...
Delphi Compiler Error X2269 Overriding virtual method ‘%s.%s’ has lower visibility (%s) than base class ‘%s’ (%s) Reason for the...