diff --git a/Compiler/PCU/PCUReader.cs b/Compiler/PCU/PCUReader.cs index 42acd1a4e..9fa3a2d72 100644 --- a/Compiler/PCU/PCUReader.cs +++ b/Compiler/PCU/PCUReader.cs @@ -1335,7 +1335,7 @@ namespace PascalABCCompiler.PCU loc = ReadDebugInfo(); type_node elem_type = GetTypeReference(); int rank = br.ReadInt32(); - return type_constructor.instance.create_unsized_array(elem_type, null, rank, loc); + return type_constructor.instance.create_unsized_array(elem_type, rank, loc); case 6: return GetTemplateInstance(); case 7: diff --git a/TestSuite/units/u_common_arr1_0.pas b/TestSuite/units/u_common_arr1_0.pas new file mode 100644 index 000000000..166dc8cbd --- /dev/null +++ b/TestSuite/units/u_common_arr1_0.pas @@ -0,0 +1,6 @@ +unit u_common_arr1_0; + +uses u_common_arr1_1; +uses u_common_arr1_2; + +end. \ No newline at end of file diff --git a/TestSuite/units/u_common_arr1_1.pas b/TestSuite/units/u_common_arr1_1.pas new file mode 100644 index 000000000..217ff8b77 --- /dev/null +++ b/TestSuite/units/u_common_arr1_1.pas @@ -0,0 +1,7 @@ +unit u_common_arr1_1; + + uses u_common_arr1_3; + + var v1: array of c3; + +end. \ No newline at end of file diff --git a/TestSuite/units/u_common_arr1_2.pas b/TestSuite/units/u_common_arr1_2.pas new file mode 100644 index 000000000..7206d325a --- /dev/null +++ b/TestSuite/units/u_common_arr1_2.pas @@ -0,0 +1,7 @@ +unit u_common_arr1_2; + + uses u_common_arr1_3; + + var v2: array of c3; + +end. \ No newline at end of file diff --git a/TestSuite/units/u_common_arr1_3.pas b/TestSuite/units/u_common_arr1_3.pas new file mode 100644 index 000000000..13c5cf9d4 --- /dev/null +++ b/TestSuite/units/u_common_arr1_3.pas @@ -0,0 +1,6 @@ +unit u_common_arr1_3; + +type + c3 = class end; + +end. \ No newline at end of file diff --git a/TestSuite/usesunits/use_common_arr1.pas b/TestSuite/usesunits/use_common_arr1.pas new file mode 100644 index 000000000..886a55481 --- /dev/null +++ b/TestSuite/usesunits/use_common_arr1.pas @@ -0,0 +1,5 @@ +## uses u_common_arr1_1, u_common_arr1_2; + +// Проверяем что типы всё ещё совместимые +v1 := v2; +v2 := v1; \ No newline at end of file diff --git a/TreeConverter/TreeConversion/syntax_tree_visitor.cs b/TreeConverter/TreeConversion/syntax_tree_visitor.cs index e0d4d0612..99e9b2000 100644 --- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs +++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs @@ -14951,8 +14951,7 @@ namespace PascalABCCompiler.TreeConverter //AddError(new VoidNotValid(get_location(_array_type.elemets_types))); check_for_type_allowed(et,get_location(_array_type.elements_type)); check_using_static_class(et, get_location(_array_type.elements_type)); - ret = convertion_data_and_alghoritms.type_constructor.create_unsized_array(et, - context.converted_namespace, rank, get_location(_array_type)); + ret = convertion_data_and_alghoritms.type_constructor.create_unsized_array(et, rank, get_location(_array_type)); return_value(ret); return; } @@ -17237,7 +17236,7 @@ namespace PascalABCCompiler.TreeConverter if (tn is undefined_type || tn is null_type_node) { if (tn is ArrayConstType) - return convertion_data_and_alghoritms.type_constructor.create_unsized_array((tn as ArrayConstType).element_type, context.converted_namespace, 1, loc); + return convertion_data_and_alghoritms.type_constructor.create_unsized_array(((ArrayConstType)tn).element_type, 1, loc); AddError(loc, "CAN_NOT_DEDUCE_TYPE_{0}", tn.name); } return tn; @@ -19645,7 +19644,7 @@ namespace PascalABCCompiler.TreeConverter //if (exprs.Count == 1) { //new typename[size] - type_node atn = convertion_data_and_alghoritms.type_constructor.create_unsized_array(tn, context.converted_namespace, exprs.Count, loc); + type_node atn = convertion_data_and_alghoritms.type_constructor.create_unsized_array(tn, exprs.Count, loc); //тип элементов typeof_operator to = new typeof_operator(tn, loc); List lst = new List(); diff --git a/TreeConverter/TreeConversion/type_constructor.cs b/TreeConverter/TreeConversion/type_constructor.cs index 68d4786f6..9ac8facf6 100644 --- a/TreeConverter/TreeConversion/type_constructor.cs +++ b/TreeConverter/TreeConversion/type_constructor.cs @@ -38,7 +38,7 @@ namespace PascalABCCompiler.TreeConverter private System.Collections.Generic.Dictionary> types_unsized_arrays = new System.Collections.Generic.Dictionary>(); - public type_node create_unsized_array(type_node element_type, common_namespace_node cmn, int rank, location loc) + public type_node create_unsized_array(type_node element_type, int rank, location loc) { List ret = null; if(types_unsized_arrays.TryGetValue(element_type,out ret)) @@ -79,15 +79,10 @@ namespace PascalABCCompiler.TreeConverter SystemLibrary.SystemLibrary.init_reference_type(ctn); return ctn; } - SymbolTable.Scope top_scope = null; - if (cmn != null) - { - top_scope = cmn.scope; - } common_type_node comtn = new common_type_node(SystemLibrary.SystemLibrary.array_base_type, StringConstants.get_array_type_name(element_type.name,rank), SemanticTree.type_access_level.tal_public, - cmn, convertion_data_and_alghoritms.symbol_table.CreateClassScope(top_scope,SystemLibrary.SystemLibrary.array_base_type.Scope), loc); + null, convertion_data_and_alghoritms.symbol_table.CreateClassScope(null, SystemLibrary.SystemLibrary.array_base_type.Scope), loc); comtn.internal_type_special_kind = SemanticTree.type_special_kind.array_kind; comtn.is_class = true; comtn.add_internal_interface(aii); diff --git a/TreeConverter/TreeRealization/generics.cs b/TreeConverter/TreeRealization/generics.cs index 97747d15b..bd9ffa812 100644 --- a/TreeConverter/TreeRealization/generics.cs +++ b/TreeConverter/TreeRealization/generics.cs @@ -1,4 +1,4 @@ -// Copyright (c) Ivan Bondarev, Stanislav Mikhalkovich (for details please see \doc\copyright.txt) +// Copyright (c) Ivan Bondarev, Stanislav Mikhalkovich (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) //Здесь описана реализация generic-типов //Файлом владеет ssyy. @@ -508,7 +508,7 @@ namespace PascalABCCompiler.TreeRealization type_node elem_tp = determine_type(ii.element_type, param_types, method_param_types, generic_param_types); if (elem_tp != ii.element_type) { - return SystemLibrary.SystemLibrary.syn_visitor.convertion_data_and_alghoritms.type_constructor.create_unsized_array(elem_tp, null, ii.rank, null); + return SystemLibrary.SystemLibrary.syn_visitor.convertion_data_and_alghoritms.type_constructor.create_unsized_array(elem_tp, ii.rank, null); } return tn; } @@ -555,7 +555,7 @@ namespace PascalABCCompiler.TreeRealization type_node elem_tp = determine_type(comm_type.element_type, param_types, method_param_types, generic_param_types); if (elem_tp != comm_type.element_type) { - return SystemLibrary.SystemLibrary.syn_visitor.convertion_data_and_alghoritms.type_constructor.create_unsized_array(elem_tp, null, 1, comm_type.loc); + return SystemLibrary.SystemLibrary.syn_visitor.convertion_data_and_alghoritms.type_constructor.create_unsized_array(elem_tp, 1, comm_type.loc); } return tn; } diff --git a/bin/TestRunner.exe b/bin/TestRunner.exe index 9c8bcbab5..ff3b098b3 100644 Binary files a/bin/TestRunner.exe and b/bin/TestRunner.exe differ diff --git a/bin/TestRunner.pas b/bin/TestRunner.pas index a8662f001..04774ec39 100644 --- a/bin/TestRunner.pas +++ b/bin/TestRunner.pas @@ -188,6 +188,8 @@ end; procedure CompileAllUnits; begin var comp := new Compiler(); + // Не пропускать ошибки сохранения PCU, в тесте создания PCU + comp.InternalDebug.SkipPCUErrors := false; var files := Directory.GetFiles(TestSuiteDir + PathSeparator + 'units', '*.pas'); var dir := TestSuiteDir + PathSeparator + 'units' + PathSeparator; for var i := 0 to files.Length - 1 do