From 053d012565427e667f3782736c173966d2798a5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D0=BE=D0=BD=D0=B4=D0=B0=D1=80=D0=B5=D0=B2=20=D0=98?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD?= Date: Wed, 2 Jan 2019 22:40:04 +0100 Subject: [PATCH] fix #1345 --- TestSuite/errors/err0307.pas | 7 +++++++ TreeConverter/TreeConversion/syntax_tree_visitor.cs | 2 ++ bin/Lng/Eng/SemanticErrors_ib.dat | 1 + bin/Lng/Rus/SemanticErrors_ib.dat | 1 + bin/Lng/Ukr/SemanticErrors_ib.dat | 1 + 5 files changed, 12 insertions(+) create mode 100644 TestSuite/errors/err0307.pas diff --git a/TestSuite/errors/err0307.pas b/TestSuite/errors/err0307.pas new file mode 100644 index 000000000..819bbe700 --- /dev/null +++ b/TestSuite/errors/err0307.pas @@ -0,0 +1,7 @@ +type + I1 = interface + procedure operator+=(x, y: I1); + end; + +begin +end. \ No newline at end of file diff --git a/TreeConverter/TreeConversion/syntax_tree_visitor.cs b/TreeConverter/TreeConversion/syntax_tree_visitor.cs index 3d65557bf..b4e366b37 100644 --- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs +++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs @@ -9823,6 +9823,8 @@ namespace PascalABCCompiler.TreeConverter definition_node def_temp = null; SyntaxTree.template_type_name ttn = null; bool is_operator = _method_name.meth_name is SyntaxTree.operator_name_ident; + if (is_operator && context.converted_type != null && context.converted_type.IsInterface) + AddError(get_location(_method_name), "OPERATORS_IN_INTERFACES_NOT_ALLOWED"); SyntaxTree.Operators op = PascalABCCompiler.SyntaxTree.Operators.Undefined; if(is_operator) op=(_method_name.meth_name as SyntaxTree.operator_name_ident).operator_type; diff --git a/bin/Lng/Eng/SemanticErrors_ib.dat b/bin/Lng/Eng/SemanticErrors_ib.dat index 15842b64d..661e7ea6f 100644 --- a/bin/Lng/Eng/SemanticErrors_ib.dat +++ b/bin/Lng/Eng/SemanticErrors_ib.dat @@ -159,6 +159,7 @@ INTERFACE_PROPERTIES_CANNOT_BE_STATIC=Interface properties can not be static ARRAY_RANK_CANNOT_BE_GREATER_32=Rank of multidimensional unsized array cannot be greater 32 CANNOT_GET_POINTER_TO_DISPOSE=Cannot get a pointer to intrinsic procedure Dispose USING_{0}_NOT_ALLOWED_IN_THIS_CONTEXT=Using of {0} is not allowed in this context +OPERATORS_IN_INTERFACES_NOT_ALLOWED=Interfaces can not contain operators %PREFIX%=COMPILATIONERROR_ UNIT_MODULE_EXPECTED_LIBRARY_FOUND=Unit expected, library found ASSEMBLY_{0}_READING_ERROR=Error by reading assembly '{0}' diff --git a/bin/Lng/Rus/SemanticErrors_ib.dat b/bin/Lng/Rus/SemanticErrors_ib.dat index 2f7663a4e..3b1f216fd 100644 --- a/bin/Lng/Rus/SemanticErrors_ib.dat +++ b/bin/Lng/Rus/SemanticErrors_ib.dat @@ -154,6 +154,7 @@ INTERFACE_PROPERTIES_CANNOT_BE_STATIC=Свойства интерфейса не ARRAY_RANK_CANNOT_BE_GREATER_32=Размерность многомерного динамического массива не может быть больше 32 CANNOT_GET_POINTER_TO_DISPOSE=Нельзя получить указатель на процедуру Dispose USING_{0}_NOT_ALLOWED_IN_THIS_CONTEXT=Использование {0} недопустимо в данном контексте +OPERATORS_IN_INTERFACES_NOT_ALLOWED=Интерфейсы не могут содержать операторы %PREFIX%=COMPILATIONERROR_ UNIT_MODULE_EXPECTED_LIBRARY_FOUND=Ожидался модуль, а встречена библиотека ASSEMBLY_{0}_READING_ERROR=Ошибка при чтении сборки '{0}' diff --git a/bin/Lng/Ukr/SemanticErrors_ib.dat b/bin/Lng/Ukr/SemanticErrors_ib.dat index 5d3fceeef..a2ac83875 100644 --- a/bin/Lng/Ukr/SemanticErrors_ib.dat +++ b/bin/Lng/Ukr/SemanticErrors_ib.dat @@ -151,6 +151,7 @@ INTERFACE_PROPERTIES_CANNOT_BE_STATIC=Свойства интерфейса не ARRAY_RANK_CANNOT_BE_GREATER_32=Размерность многомерного динамического массива не может быть больше 32 CANNOT_GET_POINTER_TO_DISPOSE=Нельзя получить указатель на процедуру Dispose USING_{0}_NOT_ALLOWED_IN_THIS_CONTEXT=Использование {0} недопустимо в данном контексте +OPERATORS_IN_INTERFACES_NOT_ALLOWED=Интерфейсы не могут содержать операторы %PREFIX%=COMPILATIONERROR_ UNIT_MODULE_EXPECTED_LIBRARY_FOUND=Очікувався модуль, а зустріли бібліотеку ASSEMBLY_{0}_READING_ERROR=Помилка при читанні збірки '{0}'