From e15f731a9b1ce32f5e44116362a457eb902499a2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Van=20Canneyt?= <michael@freepascal.org>
Date: Mon, 25 Nov 2024 14:11:42 +0100
Subject: [PATCH] * Allow to parse internal symbol names generated for
 generics.

---
 compiler/scanner.pas  | 6 +++++-
 compiler/symcreat.pas | 1 +
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/compiler/scanner.pas b/compiler/scanner.pas
index 6177186a63..39c9de4e17 100644
--- a/compiler/scanner.pas
+++ b/compiler/scanner.pas
@@ -174,6 +174,8 @@ interface
           in_preproc_comp_expr : boolean;
           { true if tokens must be converted to opposite endianess}
           change_endian_for_replay : boolean;
+          { hack to allow reading generic generated identifiers IDs}
+          allowgenericid : boolean;
 
           constructor Create(const fn:string; is_macro: boolean = false);
           destructor Destroy;override;
@@ -4523,11 +4525,13 @@ type
         i:=0;
         repeat
           case c of
-            '_',
+            '_','$',
             '0'..'9',
             'A'..'Z',
             'a'..'z' :
               begin
+                if (c='$') and not allowgenericid then
+                  break;
                 if i<255 then
                  begin
                    inc(i);
diff --git a/compiler/symcreat.pas b/compiler/symcreat.pas
index 8603bf62b3..930bf33b73 100644
--- a/compiler/symcreat.pas
+++ b/compiler/symcreat.pas
@@ -1813,6 +1813,7 @@ implementation
     if ErrorCount<>0 then
       exit;
     replace_scanner('hiddenclass_impl',sstate);
+    sstate.new_scanner.allowgenericid:=true;
     for i:=0 to st.deflist.count-1 do
       begin
       def:=tdef(st.deflist[i]);