From 129cefd7e769260b92615a72ac78adde14398687 Mon Sep 17 00:00:00 2001 From: Mikhalkovich Stanislav Date: Thu, 25 Jun 2020 00:03:11 +0300 Subject: [PATCH] fix #2271 --- Configuration/GlobalAssemblyInfo.cs | 2 +- Configuration/Version.defs | 2 +- Localization/DefaultLang.resources | Bin 94374 -> 94460 bytes Release/pabcversion.txt | 2 +- ReleaseGenerators/PascalABCNET_version.nsh | 2 +- TestSuite/gotobad0.pas | 9 +++++++++ TestSuite/gotobad1.pas | 13 ++++++++++++ TestSuite/gotobad2.pas | 15 ++++++++++++++ .../TreeConversion/syntax_tree_visitor.cs | 19 +++++++++++++++++- 9 files changed, 59 insertions(+), 5 deletions(-) create mode 100644 TestSuite/gotobad0.pas create mode 100644 TestSuite/gotobad1.pas create mode 100644 TestSuite/gotobad2.pas diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index fdfb7f50c..580b08262 100644 --- a/Configuration/GlobalAssemblyInfo.cs +++ b/Configuration/GlobalAssemblyInfo.cs @@ -15,7 +15,7 @@ internal static class RevisionClass public const string Major = "3"; public const string Minor = "6"; public const string Build = "3"; - public const string Revision = "2523"; + public const string Revision = "2527"; public const string MainVersion = Major + "." + Minor; public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision; diff --git a/Configuration/Version.defs b/Configuration/Version.defs index b7cd4ce3e..d6c797f24 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ %MINOR%=6 -%REVISION%=2523 +%REVISION%=2527 %COREVERSION%=3 %MAJOR%=3 diff --git a/Localization/DefaultLang.resources b/Localization/DefaultLang.resources index a546fc604d8ace32121d6a566d5647e2b431ddbd..9b8561282559b28e6aaa416339f46aa7af997985 100644 GIT binary patch delta 75 zcmV-R0JQ(6;RXER1(4tZ7;v%T537^WloTFFK~_ayP*O!iMMg61{c7Yp#^ b); + if True then + goto 1; + 1: Assert(1=1); +end. diff --git a/TestSuite/gotobad1.pas b/TestSuite/gotobad1.pas new file mode 100644 index 000000000..ac92e5775 --- /dev/null +++ b/TestSuite/gotobad1.pas @@ -0,0 +1,13 @@ +// #2271 +procedure p; +label 1; +begin + Arr(3).Select(b -> b); + if True then + goto 1; + 1: Assert(1=1); +end; + +begin + p; +end. diff --git a/TestSuite/gotobad2.pas b/TestSuite/gotobad2.pas new file mode 100644 index 000000000..327764fd0 --- /dev/null +++ b/TestSuite/gotobad2.pas @@ -0,0 +1,15 @@ +// #2271 +type + A = class + procedure p; + label 1; + begin + Arr(3).Select(b -> b); + if True then + goto 1; + 1: Print(1); + end; + end; + +begin +end. diff --git a/TreeConverter/TreeConversion/syntax_tree_visitor.cs b/TreeConverter/TreeConversion/syntax_tree_visitor.cs index a7ceb1829..2ed7cf32e 100644 --- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs +++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs @@ -2767,6 +2767,22 @@ namespace PascalABCCompiler.TreeConverter lambdaProcessingState = LambdaProcessingState.TypeInferencePhase; visit_program_code(_block.program_code); + // Очистили списки goto для меток перед следующим этапом - пока ничего не дало - закомментируем + foreach (var l in context._cmn.labels) + { + l.goto_statements.Clear(); + l.comprehensive_code_block = null; + } + if (context.func_stack.size > 0) + { + var fun = context.func_stack.top(); + foreach (var l in fun.label_nodes_list) + { + l.goto_statements.Clear(); + l.comprehensive_code_block = null; + } + } + // Грубо - удаление мусора при разборе лямбд. Происходит исключение - заголовок разбирается, тело остается пустым - и из-за этого была ошибка #1270. while (context._cmn.functions.Count > 0 && context._cmn.functions[context._cmn.functions.Count-1].function_code == null && context._cmn.functions[context._cmn.functions.Count - 1].name.StartsWith("<>lambda") && !context._cmn.functions[context._cmn.functions.Count - 1].name.StartsWith("<>lambda_initializer")) { @@ -8918,7 +8934,8 @@ namespace PascalABCCompiler.TreeConverter lab.goto_statements.Add(gs); if (lab.comprehensive_code_block != null) { - if (!context.check_can_goto(lab.comprehensive_code_block, gs.comprehensive_code_block) && _goto_statement.source_context != null) + // последнее условие - для goto, которые генерируются в автомате yield, не рассматривать эту ошибку + if (!context.check_can_goto(lab.comprehensive_code_block, gs.comprehensive_code_block) && _goto_statement.source_context != null) { AddError(gs.location, "BLOCKED_LABEL_{0}_GOTO", lab.name); }