From b79bcd904e1cf662b53a748268da726c954f6aed Mon Sep 17 00:00:00 2001 From: Mikhalkovich Stanislav Date: Mon, 11 Jan 2021 00:09:28 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B5=D0=B1=D0=BE=D0=BB=D1=8C=D1=88?= =?UTF-8?q?=D0=B0=D1=8F=20=D0=BE=D0=BF=D1=82=D0=B8=D0=BC=D0=B8=D0=B7=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D1=8F=20=D1=81=20#2401?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Configuration/GlobalAssemblyInfo.cs | 2 +- Configuration/Version.defs | 2 +- Release/pabcversion.txt | 2 +- ReleaseGenerators/PascalABCNET_version.nsh | 2 +- TestSuite/CompilationSamples/PABCSystem.pas | 16 ++++++++-------- TestSuite/fResult2.pas | 12 ++++++++++++ TestSuite/fResult3.pas | 15 +++++++++++++++ .../convertion_data_and_alghoritms.cs | 2 +- .../TreeConversion/syntax_tree_visitor.cs | 11 +++++++---- bin/Lib/PABCSystem.pas | 16 ++++++++-------- 10 files changed, 55 insertions(+), 25 deletions(-) create mode 100644 TestSuite/fResult2.pas create mode 100644 TestSuite/fResult3.pas diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index 4f5f91bef..46048dceb 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 = "7"; public const string Build = "1"; - public const string Revision = "2794"; + public const string Revision = "2796"; 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 b7973cb81..eb612e9c8 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ %COREVERSION%=1 -%REVISION%=2794 +%REVISION%=2796 %MINOR%=7 %MAJOR%=3 diff --git a/Release/pabcversion.txt b/Release/pabcversion.txt index e023f62c9..a3dcbc816 100644 --- a/Release/pabcversion.txt +++ b/Release/pabcversion.txt @@ -1 +1 @@ -3.7.1.2794 +3.7.1.2796 diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index 62e5db2f7..aa6d3386c 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.7.1.2794' +!define VERSION '3.7.1.2796' diff --git a/TestSuite/CompilationSamples/PABCSystem.pas b/TestSuite/CompilationSamples/PABCSystem.pas index a53568731..1c9f37d7c 100644 --- a/TestSuite/CompilationSamples/PABCSystem.pas +++ b/TestSuite/CompilationSamples/PABCSystem.pas @@ -1882,10 +1882,10 @@ function Length(s: string): integer; procedure SetLength(var s: string; n: integer); ///-- procedure SetLengthForShortString(var s: string; n, sz: integer); -/// Вставляет подстроку source в строку s с позиции index -procedure Insert(source: string; var s: string; index: integer); +/// Вставляет подстроку subs в строку s с позиции index +procedure Insert(subs: string; var s: string; index: integer); ///-- -procedure InsertInShortString(source: string; var s: string; index, n: integer); +procedure InsertInShortString(subs: string; var s: string; index, n: integer); /// Удаляет из строки s count символов с позиции index procedure Delete(var s: string; index, count: integer); /// Возвращает подстроку строки s длины count с позиции index @@ -8842,27 +8842,27 @@ begin s += new String(' ', sz - s.Length) end; -procedure Insert(source: string; var s: string; index: integer); +procedure Insert(subs: string; var s: string; index: integer); // Insert никогда не возвращает исключения begin if index < 1 then index := 1; if index > s.Length + 1 then index := s.Length + 1; - s := s.Insert(index - 1, source); + s := s.Insert(index - 1, subs); end; -procedure InsertInShortString(source: string; var s: string; index, n: integer); +procedure InsertInShortString(subs: string; var s: string; index, n: integer); begin if index < 1 then index := 1; if index > n then exit; try - s := s.Insert(index - 1, source); + s := s.Insert(index - 1, subs); if s.Length > n then s := s.Substring(0, n); except - s := s.Insert(s.Length, source); + s := s.Insert(s.Length, subs); if s.Length > n then s := s.Substring(0, n); end; end; diff --git a/TestSuite/fResult2.pas b/TestSuite/fResult2.pas new file mode 100644 index 000000000..33f8f427b --- /dev/null +++ b/TestSuite/fResult2.pas @@ -0,0 +1,12 @@ +function Sum(a,b: integer): integer; +begin + var Sum := 0; + for var i:=a to b do + begin + Sum := Sum + i; + end; +end; + +begin + Assert(Sum(1,10)=0); +end. \ No newline at end of file diff --git a/TestSuite/fResult3.pas b/TestSuite/fResult3.pas new file mode 100644 index 000000000..740b7f3d1 --- /dev/null +++ b/TestSuite/fResult3.pas @@ -0,0 +1,15 @@ +procedure p; + +function Sum(a,b: integer): integer; +begin + var Sum := 0; + Sum := 666; +end; + +begin + Assert(Sum(1,10)=0); +end; + +begin + p; +end. \ No newline at end of file diff --git a/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs b/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs index aeb6159d0..7714f2a48 100644 --- a/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs +++ b/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs @@ -1871,7 +1871,7 @@ namespace PascalABCCompiler.TreeConverter mc = method_compare.greater_method; } } - if (mc == method_compare.greater_method) + if (mc == method_compare.greater_method) // f[i]>f[j] - значит, удалять надо f[i], а в коде наоборот!!! Странно... { tcll.remove_at(j); set_of_possible_functions.RemoveAt(j); diff --git a/TreeConverter/TreeConversion/syntax_tree_visitor.cs b/TreeConverter/TreeConversion/syntax_tree_visitor.cs index 3fc6f1755..b1758c94c 100644 --- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs +++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs @@ -17056,11 +17056,14 @@ namespace PascalABCCompiler.TreeConverter if (sil == null) { int comp = SystemLibrary.SystemLibrary.string_comparer.Compare(_ident.name, context.top_function.name); - List mysi = context.find(_ident.name); - if (comp == 0 && mysi != null && mysi[0].sym_info is function_node) // мы нашли функцию и ее имя совпадает с ident + if (comp == 0) // мы нашли функцию и ее имя совпадает с ident { - local_variable lv = context.top_function.return_variable; - return new local_variable_reference(lv, 0, get_location(_ident)); + List mysi = context.find(_ident.name); + if (mysi != null && mysi[0].sym_info is function_node) + { + local_variable lv = context.top_function.return_variable; + return new local_variable_reference(lv, 0, get_location(_ident)); + } } } } diff --git a/bin/Lib/PABCSystem.pas b/bin/Lib/PABCSystem.pas index a53568731..1c9f37d7c 100644 --- a/bin/Lib/PABCSystem.pas +++ b/bin/Lib/PABCSystem.pas @@ -1882,10 +1882,10 @@ function Length(s: string): integer; procedure SetLength(var s: string; n: integer); ///-- procedure SetLengthForShortString(var s: string; n, sz: integer); -/// Вставляет подстроку source в строку s с позиции index -procedure Insert(source: string; var s: string; index: integer); +/// Вставляет подстроку subs в строку s с позиции index +procedure Insert(subs: string; var s: string; index: integer); ///-- -procedure InsertInShortString(source: string; var s: string; index, n: integer); +procedure InsertInShortString(subs: string; var s: string; index, n: integer); /// Удаляет из строки s count символов с позиции index procedure Delete(var s: string; index, count: integer); /// Возвращает подстроку строки s длины count с позиции index @@ -8842,27 +8842,27 @@ begin s += new String(' ', sz - s.Length) end; -procedure Insert(source: string; var s: string; index: integer); +procedure Insert(subs: string; var s: string; index: integer); // Insert никогда не возвращает исключения begin if index < 1 then index := 1; if index > s.Length + 1 then index := s.Length + 1; - s := s.Insert(index - 1, source); + s := s.Insert(index - 1, subs); end; -procedure InsertInShortString(source: string; var s: string; index, n: integer); +procedure InsertInShortString(subs: string; var s: string; index, n: integer); begin if index < 1 then index := 1; if index > n then exit; try - s := s.Insert(index - 1, source); + s := s.Insert(index - 1, subs); if s.Length > n then s := s.Substring(0, n); except - s := s.Insert(s.Length, source); + s := s.Insert(s.Length, subs); if s.Length > n then s := s.Substring(0, n); end; end;