From 3f1d62af8e91db86d04cf42c094e17e64eabd258 Mon Sep 17 00:00:00 2001 From: Sven/Sarah Barth Date: Tue, 7 Nov 2023 20:33:55 +0100 Subject: [PATCH] * fix #40504: always provide the global enum symbol for anonymous enum types (e.g. as part of a set) + added test --- compiler/ptype.pas | 4 +++- tests/webtbs/tw40504.pp | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 tests/webtbs/tw40504.pp diff --git a/compiler/ptype.pas b/compiler/ptype.pas index 4073658a7c..8c527396b4 100644 --- a/compiler/ptype.pas +++ b/compiler/ptype.pas @@ -1789,7 +1789,9 @@ implementation else Message(parser_e_enumeration_out_of_range); tenumsymtable(aktenumdef.symtable).insertsym(cenumsym.create(s,aktenumdef,longint(l.svalue))); - if not (cs_scopedenums in current_settings.localswitches) then + if not (cs_scopedenums in current_settings.localswitches) or + { also provide the global symbol for anonymous enums } + not assigned(newsym) then tstoredsymtable(aktenumdef.owner).insertsym(cenumsym.create(s,aktenumdef,longint(l.svalue))); current_tokenpos:=storepos; end; diff --git a/tests/webtbs/tw40504.pp b/tests/webtbs/tw40504.pp new file mode 100644 index 0000000000..5c5c2b65bf --- /dev/null +++ b/tests/webtbs/tw40504.pp @@ -0,0 +1,17 @@ +{ %NORUN } + +program tw40504; + +{$scopedenums on} + +Type + TSet = set of (a,b); + +var + S : TSet; + +begin + S:=[]; + Include(S,a); +end. +