From ace3bd61640420c7baa7164754ede5ddbbc9a7f0 Mon Sep 17 00:00:00 2001 From: Mikhalkovich Stanislav Date: Sat, 27 Jun 2020 16:38:15 +0300 Subject: [PATCH] fix #1416 --- Configuration/GlobalAssemblyInfo.cs | 2 +- Configuration/Version.defs | 4 ++-- Localization/DefaultLang.resources | Bin 94560 -> 94700 bytes Release/pabcversion.txt | 2 +- ReleaseGenerators/PascalABCNET_version.nsh | 2 +- TestSuite/anon.pas | 7 ++++++ ...uredVariablesSubstitutionClassGenerator.cs | 2 +- .../TreeConversion/syntax_tree_visitor.cs | 22 ++++++++++++++++-- 8 files changed, 33 insertions(+), 8 deletions(-) create mode 100644 TestSuite/anon.pas diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index 5044ce5d0..d461bcf42 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 = "2534"; + public const string Revision = "2537"; 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 557034129..ca93fea4c 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ -%COREVERSION%=3 -%REVISION%=2534 %MINOR%=6 +%REVISION%=2537 +%COREVERSION%=3 %MAJOR%=3 diff --git a/Localization/DefaultLang.resources b/Localization/DefaultLang.resources index c361510b601c05f9cd489be91addc6043c156d7d..a6568ff893864a6c72530dfec6af295b4e59b39b 100644 GIT binary patch delta 152 zcmaFxi1p25)(H=oI0`pD^1C>B@jAi!;835Ccu&9hYJ*zavrk_B(D!h2} zUm+;9xHP9k;gJGRQbFU<(+}_d1Lbsp0`H!@efLJ;#dC#6uirg;`u6SbuL`gKzj^rN zf$pQ-T>8oQh50Llft9l-(P%u{q(ISFBdP@W|K=g^8u^X BU-tk2 delta 24 icmV+z0O$Yg;|1X21(4tZd~mViPSKOln-#Os(i@+zgALCB diff --git a/Release/pabcversion.txt b/Release/pabcversion.txt index 1ed246cc4..56c8da751 100644 --- a/Release/pabcversion.txt +++ b/Release/pabcversion.txt @@ -1 +1 @@ -3.6.3.2534 +3.6.3.2537 diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index 0caf2e879..79eb7d762 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.6.3.2534' +!define VERSION '3.6.3.2537' diff --git a/TestSuite/anon.pas b/TestSuite/anon.pas new file mode 100644 index 000000000..ae7fd717c --- /dev/null +++ b/TestSuite/anon.pas @@ -0,0 +1,7 @@ +// #1416 +function f1 := 5; + +begin + var o := new class(a := f1); + Assert(o.a = 5); +end. \ No newline at end of file diff --git a/TreeConverter/LambdaExpressions/Closure/CapturedVariablesSubstitutionClassGenerator.cs b/TreeConverter/LambdaExpressions/Closure/CapturedVariablesSubstitutionClassGenerator.cs index 613259950..ae4d71d4a 100644 --- a/TreeConverter/LambdaExpressions/Closure/CapturedVariablesSubstitutionClassGenerator.cs +++ b/TreeConverter/LambdaExpressions/Closure/CapturedVariablesSubstitutionClassGenerator.cs @@ -706,7 +706,7 @@ namespace TreeConverter.LambdaExpressions.Closure .ToList(); var fieldNames = vars - .Select(var => new ident(var.name,(var as local_variable).loc)) + .Select(var => new ident(var.name,(var as local_variable)?.loc ?? null)) .ToList(); var fieldTypes = vars diff --git a/TreeConverter/TreeConversion/syntax_tree_visitor.cs b/TreeConverter/TreeConversion/syntax_tree_visitor.cs index 572a0fcc0..473c6715f 100644 --- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs +++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs @@ -16706,6 +16706,9 @@ namespace PascalABCCompiler.TreeConverter sil, lloc, context.converted_type, context.top_function, false); if (!(sil.FirstOrDefault().sym_info is common_in_function_function_node)) { + var ex = sil.FirstOrDefault().sym_info as basic_function_node; + if (ex != null && ex.name.ToLower() == "exit") + return new basic_function_call(ex, ex.location); return make_delegate_wrapper(null, sil, lloc, ((sil.FirstOrDefault().sym_info is common_method_node) && ((common_method_node)sil.FirstOrDefault().sym_info).IsStatic)); } return convertion_data_and_alghoritms.create_full_function_call(new expressions_list(), @@ -19657,8 +19660,15 @@ namespace PascalABCCompiler.TreeConverter try { qq = convert_strong(ff.dereferencing_value); + if (qq is exit_procedure && stl.list.Count == 1) + { + // SSM #2172 27/06/20 - тело - это вызов exit + stl.list[0] = new procedure_call(ff, ff.source_context); + _function_lambda_definition.return_type = null; + return; + } dm = qq.type as delegated_methods; - if (dm == null && qq.type.IsDelegate) + if (dm == null && qq.type != null && qq.type.IsDelegate) delegate_type = qq.type as common_type_node; } @@ -20109,7 +20119,15 @@ namespace PascalABCCompiler.TreeConverter /*var tt1 = l.name_expr[0].expr; var tse = convert_strong(tt1);*/ - var semantic_types = l.name_expr.Select(x => convert_strong(x.expr).type).ToList(); + var semantic_exprs = l.name_expr.Select(x => convert_strong(x.expr)).ToList(); + for (var i = 0; i < semantic_exprs.Count; i++) + { + var ex = semantic_exprs[i]; + try_convert_typed_expression_to_function_call(ref ex); + semantic_exprs[i] = ex; + } + + var semantic_types = semantic_exprs.Select(x => x.type).ToList(); var types = semantic_types.Select(x => SyntaxTreeBuilder.BuildSemanticType(x)).ToList(); contextChanger.SaveContextAndUpToGlobalLevel();