diff --git a/CodeCompletion/CodeFormatter.cs b/CodeCompletion/CodeFormatter.cs index cef80f129..21a07ecd0 100644 --- a/CodeCompletion/CodeFormatter.cs +++ b/CodeCompletion/CodeFormatter.cs @@ -698,7 +698,7 @@ namespace CodeFormatters || sn is foreach_stmt || sn is var_statement || sn is try_stmt || sn is goto_statement || sn is with_statement || sn is case_node || sn is function_header || sn is procedure_header || sn is constructor || sn is destructor || sn is type_declarations || sn is consts_definitions_list - || sn is label_definitions || sn is class_definition || sn is uses_list || sn is uses_closure || sn is unit_name || sn is program_name || + || sn is label_definitions || sn is class_definition || sn is uses_list || sn is uses_closure || sn is unit_or_namespace || sn is unit_name || sn is program_name || sn is new_expr || sn is raise_stmt || sn is interface_node || sn is implementation_node || sn is lock_stmt || sn is loop_stmt || sn is simple_property || sn is read_accessor_name || sn is write_accessor_name || sn is formal_parameters || sn is bracket_expr || sn is record_const || sn is array_const || sn is exception_handler @@ -1451,7 +1451,9 @@ namespace CodeFormatters public override void visit(uses_list _uses_list) { //sb.Append("uses"); - IncOffset(tab + "uses".Length - 1); + IncOffset(); + if (options.AggressiveMode == 1) + insert_newline_after_prev = true; for (int i = 0; i < _uses_list.units.Count; i++) { if (i > 0) @@ -1459,7 +1461,7 @@ namespace CodeFormatters visit_node(_uses_list.units[i]); } insert_newline_after_prev = true; - DecOffset(tab + "uses".Length - 1); + DecOffset(); } public override void visit(unit_module _unit_module) diff --git a/NETGenerator/NETGenerator.cs b/NETGenerator/NETGenerator.cs index 43bf96125..284ee34f2 100644 --- a/NETGenerator/NETGenerator.cs +++ b/NETGenerator/NETGenerator.cs @@ -7908,7 +7908,7 @@ namespace PascalABCCompiler.NETGenerator if (value.indices == null) { value.index.visit(this); - if (from is IBasicFunctionCallNode && (from as IBasicFunctionCallNode).real_parameters[0] == to) + if (from is IBasicFunctionCallNode && (from as IBasicFunctionCallNode).real_parameters[0] == to && current_index_lb == null) { index_lb = il.DeclareLocal(helper.GetTypeReference(value.index.type).tp); il.Emit(OpCodes.Stloc, index_lb); @@ -9029,7 +9029,10 @@ namespace PascalABCCompiler.NETGenerator is_addr = false; is_dot_expr = false; TypeInfo ti = helper.GetTypeReference(value.array.type); + LocalBuilder tmp_current_index_lb = current_index_lb; + current_index_lb = null; value.array.visit(this); + current_index_lb = tmp_current_index_lb; bool string_getter = temp_is_addr && ti.tp == TypeFactory.StringType; LocalBuilder pin_lb = null; var indices = value.indices; diff --git a/TestSuite/arrays11.pas b/TestSuite/arrays11.pas new file mode 100644 index 000000000..a1200e63e --- /dev/null +++ b/TestSuite/arrays11.pas @@ -0,0 +1,20 @@ +type TRec = record + k: array[0..1, 0..1] of integer; +end; +var + k: array[0..1, 0..1] of integer; + a: array[0..10] of integer; + a2: array[1..2] of TRec; + +begin + a[5] := 1; + k[0, 1] := 100; + k[a[5] mod 2][1] += 1; + assert(k[a[5], 1] = 1); + k[a[5] mod 2, 1] += 1; + assert(k[a[5], 1] = 2); + k[0, a[a[1] + 4] mod 2] += 1; + assert(k[0, a[4] mod 2] = 1); + a2[a[5]].k[a[5] mod 2,1] += 1; + assert(a2[a[5]].k[a[5] mod 2,1] = 1); +end. \ No newline at end of file diff --git a/TestSuite/arrays9.pas b/TestSuite/arrays9.pas index a2b5cfeef..dc8a61ae7 100644 --- a/TestSuite/arrays9.pas +++ b/TestSuite/arrays9.pas @@ -16,4 +16,10 @@ begin assert(i = 2); a2[test] += a2[test]; assert(i = 4); + a2[test mod 3] += 1; + assert(i = 5); + a2[a[test]] := 0; + a2[a[test]] += 1; + assert(a2[a[test]] = 1); + assert(i = 8); end. \ No newline at end of file diff --git a/TestSuite/extensionmethods29.pas b/TestSuite/extensionmethods29.pas new file mode 100644 index 000000000..7f0612d80 --- /dev/null +++ b/TestSuite/extensionmethods29.pas @@ -0,0 +1,17 @@ +type + A = class end; + +var i: integer; + +procedure D(self: T; var a: T); extensionmethod;begin i := 1 end; + +procedure D(self: A; var b: A; var c: A); extensionmethod;begin i := 2 end; + +begin + var t := new A; + var b, c: A; + t.D(b); + assert(i = 1); + t.D(b, c); + assert(i = 2); +end. \ No newline at end of file diff --git a/TreeConverter/SymbolTable/DSST/SymbolTable.cs b/TreeConverter/SymbolTable/DSST/SymbolTable.cs index 13f48a8ad..d76ade511 100644 --- a/TreeConverter/SymbolTable/DSST/SymbolTable.cs +++ b/TreeConverter/SymbolTable/DSST/SymbolTable.cs @@ -886,6 +886,7 @@ namespace SymbolTable ((to.symbol_kind == symbol_kind.sk_overload_function) && (add.symbol_kind == symbol_kind.sk_overload_function)) || ((to.symbol_kind == symbol_kind.sk_overload_procedure) && (add.symbol_kind == symbol_kind.sk_overload_procedure)) + || to.sym_info != add.sym_info && to.sym_info is PascalABCCompiler.TreeRealization.function_node && add.sym_info is PascalABCCompiler.TreeRealization.function_node && (to.sym_info as PascalABCCompiler.TreeRealization.function_node).is_extension_method && (add.sym_info as PascalABCCompiler.TreeRealization.function_node).is_extension_method ); }