From bee059143cdc04fac16d5e048e474db1024eccfc Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Tue, 23 Jun 2026 19:45:44 +0100 Subject: [PATCH] codegen: sanitise spaces in mangled symbol names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A generic instantiated over a metaclass type argument (e.g. TList) carries a space in its type name ('class of TFoo'), which flowed unescaped into emitted assembler labels like _FieldCleanup_TListEnumerator_class of TFoo — rejected by the assembler. Map space to '_' in both the native x86_64 and QBE name manglers, alongside the existing < > , $ @ ^ handling, so metaclass-typed generic instantiations emit valid labels. --- compiler/src/main/pascal/blaise.codegen.native.x86_64.pas | 1 + compiler/src/main/pascal/blaise.codegen.qbe.pas | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/compiler/src/main/pascal/blaise.codegen.native.x86_64.pas b/compiler/src/main/pascal/blaise.codegen.native.x86_64.pas index e50ff34..445f560 100644 --- a/compiler/src/main/pascal/blaise.codegen.native.x86_64.pas +++ b/compiler/src/main/pascal/blaise.codegen.native.x86_64.pas @@ -1593,6 +1593,7 @@ begin 60: Result := Result + '_'; { '<' } 62: ; { '>' — skip } 44: Result := Result + '_'; { ',' } + 32: Result := Result + '_'; { ' ' — e.g. 'class of T' } 36: Result := Result + '_D_'; { '$' } 64: Result := Result + '_V_'; { '@' } 94: Result := Result + '_P_'; { '^' } diff --git a/compiler/src/main/pascal/blaise.codegen.qbe.pas b/compiler/src/main/pascal/blaise.codegen.qbe.pas index a791424..031d366 100644 --- a/compiler/src/main/pascal/blaise.codegen.qbe.pas +++ b/compiler/src/main/pascal/blaise.codegen.qbe.pas @@ -13123,7 +13123,7 @@ begin begin C := StrAt(AName, I); if (C = 60) or (C = 62) or (C = 44) or (C = 36) or (C = 64) or - (C = 94) then + (C = 94) or (C = 32) then begin Clean := False; break; @@ -13139,6 +13139,7 @@ begin 60: Result := Result + '_'; { '<' } 62: ; { '>' — skip } 44: Result := Result + '_'; { ',' } + 32: Result := Result + '_'; { ' ' — e.g. 'class of T' } 36: Result := Result + '_D_'; { '$' — overload delimiter } 64: Result := Result + '_V_'; { '@' — var-param prefix } 94: Result := Result + '_P_'; { '^' — pointer prefix }