Error: Operator is not overloaded: "<record type>" * "<record type>" is unclear
Summary
When you are using record types with defined operators between them, e.g. TMass, TLength, TVolume, etc, and you try to do a computation between two types that you haven't yet defined, the error message is:
Error: Operator is not overloaded: "<record type>" * "<record type>"
...which is not very helpful. This is especially the case if you're deep in an expression, e.g.:
((A * B) - C / D) + (E + F) / G
Many of the types involved are not explicitly present, e.g. "A * B" might return a new type, and "C / D" might return a new type, and those two types might not have the - operator defined, but without knowing which two types that is, you have to go and dig around and find out what you have to implement.
It'd be really nice if the compiler just reported what the types were.
Steps to reproduce
{$MODE OBJFPC}
type
TA = record end;
TB = record end;
var
A: TA;
B: TB;
begin
A * B;
end.
Among other things, this reports:
test.pas(10,6) Error: Operator is not overloaded: "<record type>" * "<record type>"
It would be more useful if it was:
test.pas(10,6) Error: Operator is not overloaded: "TA" * "TB"
System Information
- Operating system: Linux
- Processor architecture: x86-64
- Compiler version: trunk compiled on 2025/07/03
- Device: Computer
Edited by Ian Hickson