diff --git a/TestSuite/errors/err0244.pas b/TestSuite/errors/err0244.pas new file mode 100644 index 000000000..65c7f69ab --- /dev/null +++ b/TestSuite/errors/err0244.pas @@ -0,0 +1,9 @@ +type + t1=class end; + +procedure operator+=(a,b:t1) := exit; + +begin + var a := new t1; + a += new t1; +end. \ No newline at end of file diff --git a/TreeConverter/TreeConversion/syntax_tree_visitor.cs b/TreeConverter/TreeConversion/syntax_tree_visitor.cs index 651912dfe..983636108 100644 --- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs +++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs @@ -9784,10 +9784,11 @@ namespace PascalABCCompiler.TreeConverter } else { - if (is_operator && context.converted_type == null && context.converted_template_type == null && !(current_function_header != null && current_function_header.proc_attributes != null && has_extensionmethod_attr(current_function_header.proc_attributes.proc_attributes)) && !(current_function_header != null && current_function_header.template_args != null && current_function_header.template_args.idents.Count > 0)) + if (is_operator && context.converted_type == null && context.converted_template_type == null && !(current_function_header != null && current_function_header.proc_attributes != null && has_extensionmethod_attr(current_function_header.proc_attributes.proc_attributes)) /*&& !(current_function_header != null && current_function_header.template_args != null && current_function_header.template_args.idents.Count > 0)*/) { AddError(get_location(_method_name), "OVERLOADED_OPERATOR_MUST_BE_STATIC_FUNCTION"); } + } convertion_data_and_alghoritms.check_node_parser_error(_method_name.meth_name); location loc_name = get_location(_method_name.meth_name); diff --git a/bin/Lng/Rus/SemanticErrors_nv.dat b/bin/Lng/Rus/SemanticErrors_nv.dat index 349a30421..2725b54c4 100644 --- a/bin/Lng/Rus/SemanticErrors_nv.dat +++ b/bin/Lng/Rus/SemanticErrors_nv.dat @@ -95,7 +95,7 @@ INHERITED_EXPECTED_IN_CLASS=Ключевое слово inherited должно NO_BASE_CLASS_DEFINED_BUT_INHERITED_MEET=Ключевое слово inherited в методе класса, который не имеет предка NO_METHOD_{0}_IN_CLASS_{1}=Нет метода {0} в классе {1} OVERLOAD_OPERATOR_CAN_NOT_BE_PROCEDURE=Перегруженная операция не может быть процедурой -OVERLOADED_OPERATOR_MUST_BE_STATIC_FUNCTION=Перегруженная операция должна быть статической функцией +OVERLOADED_OPERATOR_MUST_BE_STATIC_FUNCTION=Перегруженная операция должна быть статической функцией класса либо методом расширения NOT_SUPPORTED_BY_THIS_VERSION_OF_COMPILER=Данная конструкция не поддерживается текущей версией компилятора NEGATIVE_ARRAY_LENGTH_({0})_NOT_ALLOWED=Отрицательная длина массива ({0}) не допустима INCOMPATIBLE_ARRAY_BOUNDS_TYPES=Несовместимые типы границ диапазона массива