From 323ba75b89188f837abfeda64feaca75d00c9e53 Mon Sep 17 00:00:00 2001 From: Mikhalkovich Stanislav Date: Mon, 1 Jul 2019 17:09:38 +0300 Subject: [PATCH] fix #2002 --- Configuration/GlobalAssemblyInfo.cs | 2 +- Configuration/Version.defs | 4 ++-- ReleaseGenerators/PascalABCNET_version.nsh | 2 +- TestSuite/CompilationSamples/PABCSystem.pas | 10 ++++++++++ TestSuite/errors/err0329.pas | 10 ++++++++++ .../TreeConversion/convertion_data_and_alghoritms.cs | 8 +++++++- TreeConverter/TreeConversion/syntax_tree_visitor.cs | 11 +++++++++++ TreeConverter/TreeRealization/types.cs | 8 ++++++-- bin/Lib/PABCSystem.pas | 10 ++++++++++ 9 files changed, 58 insertions(+), 7 deletions(-) create mode 100644 TestSuite/errors/err0329.pas diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index 8cb01b286..6c3133e8b 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 = "5"; public const string Build = "0"; - public const string Revision = "2166"; + public const string Revision = "2169"; 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 5bfdfd38e..c2071c741 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ -%COREVERSION%=0 -%REVISION%=2166 %MINOR%=5 +%REVISION%=2169 +%COREVERSION%=0 %MAJOR%=3 diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index 2ad292966..018775e1b 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.5.0.2166' +!define VERSION '3.5.0.2169' diff --git a/TestSuite/CompilationSamples/PABCSystem.pas b/TestSuite/CompilationSamples/PABCSystem.pas index 81b735561..d69b8cd78 100644 --- a/TestSuite/CompilationSamples/PABCSystem.pas +++ b/TestSuite/CompilationSamples/PABCSystem.pas @@ -901,6 +901,8 @@ procedure WritelnFormat(f: Text; formatstr: string; params args: array of object ///- procedure Print(a,b,...); /// Выводит значения a,b,... на экран, после каждого значения выводит пробел +procedure Print(o: object); +///-- procedure Print(s: string); ///-- procedure Print(params args: array of object); @@ -6126,6 +6128,14 @@ begin else Write(s) end; +procedure Print(o: object); +begin + if PrintDelimDefault<>'' then + Write(o, PrintDelimDefault) + else + Write(o) +end; + procedure Print(params args: array of object); begin if args.Length = 0 then diff --git a/TestSuite/errors/err0329.pas b/TestSuite/errors/err0329.pas new file mode 100644 index 000000000..0db05be96 --- /dev/null +++ b/TestSuite/errors/err0329.pas @@ -0,0 +1,10 @@ +function f: integer; +begin + result := 1; +end; + +begin + var a: integer; + a := f + nil; + Print(a); +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 c1db2445a..85e7e9b74 100644 --- a/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs +++ b/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs @@ -1099,7 +1099,13 @@ namespace PascalABCCompiler.TreeConverter else { ptc = type_table.get_convertions(factparams[i].type, formal_param_type); - if (ptc.first==null) + + if (factparams[i] is null_const_node && !type_table.is_with_nil_allowed(formal_param_type) && !formal_param_type.IsPointer) // SSM 01.07.19 - nil не может быть преобразована за счёт вызова функции + { + ptc.first = null; + } + + if (ptc.first==null) { if (type_table.is_derived(formal_param_type, factparams[i].type)) { diff --git a/TreeConverter/TreeConversion/syntax_tree_visitor.cs b/TreeConverter/TreeConversion/syntax_tree_visitor.cs index 47583a399..3cb2c774a 100644 --- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs +++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs @@ -1082,6 +1082,7 @@ namespace PascalABCCompiler.TreeConverter throw new CompilerInternalError("Invalid operator name"); } #endif + // Видимо, это сделано для присваивания, т.к. несимметрично. Но странно - f = nil должно возвращать boolean ! if (right.semantic_node_type == semantic_node_type.null_const_node) { if ( !type_table.is_with_nil_allowed(left.type) && !left.type.IsPointer) @@ -1089,6 +1090,13 @@ namespace PascalABCCompiler.TreeConverter right = null_const_node.get_const_node_with_type(left.type, (null_const_node)right); } + /*if (left.semantic_node_type == semantic_node_type.null_const_node) + { + if (!type_table.is_with_nil_allowed(right.type) && !right.type.IsPointer) + AddError(left.location, "NIL_WITH_VALUE_TYPES_NOT_ALLOWED"); + left = null_const_node.get_const_node_with_type(right.type, (null_const_node)left); + }*/ + type_node left_type = left.type; type_node right_type = right.type; @@ -1136,6 +1144,7 @@ namespace PascalABCCompiler.TreeConverter if (name == "+" && right_type != SystemLibrary.SystemLibrary.string_type && left_type == SystemLibrary.SystemLibrary.char_type) no_search_in_extension_methods = false; sil2 = right_type.find_in_type(name, right_type.Scope, null, no_search_in_extension_methods); + if ((sil != null) && (sil2 != null)) { //Важная проверка. Возможно один и тот же оператор с одними и теми же типами определен в двух разных классах. @@ -1288,6 +1297,8 @@ namespace PascalABCCompiler.TreeConverter } + // После этой точки right_type и left_type не используются! + expressions_list pars = null; function_node fnsel = null; if (sil != null) diff --git a/TreeConverter/TreeRealization/types.cs b/TreeConverter/TreeRealization/types.cs index 4566ea44d..024ce5bd7 100644 --- a/TreeConverter/TreeRealization/types.cs +++ b/TreeConverter/TreeRealization/types.cs @@ -196,6 +196,9 @@ namespace PascalABCCompiler.TreeRealization } } + /// + /// В частности, процедурная переменная + /// public virtual bool IsDelegate { get @@ -4259,8 +4262,9 @@ namespace PascalABCCompiler.TreeRealization } } - - //Псевдотип. Не идет в выходное дерево. Используется как промежуточный при работе с делегатами. + /// + /// Псевдотип. Не идет в выходное дерево. Используется как промежуточный при работе с делегатами. Этому типу принадлежат имена функций + /// [Serializable] public class delegated_methods : wrapped_type { diff --git a/bin/Lib/PABCSystem.pas b/bin/Lib/PABCSystem.pas index 81b735561..d69b8cd78 100644 --- a/bin/Lib/PABCSystem.pas +++ b/bin/Lib/PABCSystem.pas @@ -901,6 +901,8 @@ procedure WritelnFormat(f: Text; formatstr: string; params args: array of object ///- procedure Print(a,b,...); /// Выводит значения a,b,... на экран, после каждого значения выводит пробел +procedure Print(o: object); +///-- procedure Print(s: string); ///-- procedure Print(params args: array of object); @@ -6126,6 +6128,14 @@ begin else Write(s) end; +procedure Print(o: object); +begin + if PrintDelimDefault<>'' then + Write(o, PrintDelimDefault) + else + Write(o) +end; + procedure Print(params args: array of object); begin if args.Length = 0 then