Incompatible types: got "PROGRAM.TA" expected "TA" when actually it got TB (given type TB = type TA)

Summary

The error message that reports what type is expected vs what type was obtained reports the wrong obtained type when the type is a new type created with a type alias.

Steps to reproduce

{$MODE OBJFPC}
type
   TA = record end;
   TB = type TA;

function Foo(): TB;
begin
   Result := Default(TB);
end;

var
   A: TA;
begin
   A := Foo();
end.

This reports the following error:

test.pas(14,9) Error: Incompatible types: got "PROGRAM.TA" expected "TA"

...but should instead say:

test.pas(14,9) Error: Incompatible types: got "PROGRAM.TB" expected "TA"

...or maybe just:

test.pas(14,9) Error: Incompatible types: got "TB" expected "TA"

System Information

  • Operating system: Linux
  • Processor architecture: x86-64
  • Compiler version: trunk compiled on 2025/07/03
  • Device: Computer
Assignee Loading
Time tracking Loading