diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index bf85673b9..7e513e2ba 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 = "4"; public const string Build = "2"; - public const string Revision = "1901"; + public const string Revision = "1903"; 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 3f02095d7..51956b907 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ %COREVERSION%=2 -%REVISION%=1901 +%REVISION%=1903 %MINOR%=4 %MAJOR%=3 diff --git a/Localization/DefaultLang.resources b/Localization/DefaultLang.resources index 3df350a64..ef1661b57 100644 Binary files a/Localization/DefaultLang.resources and b/Localization/DefaultLang.resources differ diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index 4d41f7e4d..de865767c 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.4.2.1901' +!define VERSION '3.4.2.1903' diff --git a/SyntaxTree/tree/TreeHelper.cs b/SyntaxTree/tree/TreeHelper.cs index 873cdee35..e62389a16 100644 --- a/SyntaxTree/tree/TreeHelper.cs +++ b/SyntaxTree/tree/TreeHelper.cs @@ -770,13 +770,15 @@ namespace PascalABCCompiler.SyntaxTree return sb.ToString(); } - bool is_extension() + public bool is_extension() { - return proc_attributes.proc_attributes.FindIndex(attr => attr.attribute_type == proc_attribute.attr_extension) >=0; + if (proc_attributes?.proc_attributes != null) + return proc_attributes.proc_attributes.FindIndex(attr => attr.attribute_type == proc_attribute.attr_extension) >= 0; + else return false; } } - public partial class function_header + public partial class function_header { public function_header(formal_parameters _parameters, procedure_attributes_list _proc_attributes, method_name _name, where_definition_list _where_defs, type_definition _return_type, SourceContext sc) : base(_parameters, _proc_attributes, _name, _where_defs, sc) diff --git a/TestSuite/CompilationSamples/GraphWPF.pas b/TestSuite/CompilationSamples/GraphWPF.pas index 6936226ba..efd518ec2 100644 --- a/TestSuite/CompilationSamples/GraphWPF.pas +++ b/TestSuite/CompilationSamples/GraphWPF.pas @@ -459,6 +459,8 @@ var OnKeyDown: procedure(k: Key); /// Событие отжатия клавиши OnKeyUp: procedure(k: Key); + /// Событие нажатия символьной клавиши + OnKeyPress: procedure(ch: char); /// Событие изменения размера графического окна OnResize: procedure; @@ -1391,16 +1393,20 @@ begin end; /// --- SystemKeyEvents -procedure SystemOnKeyDown(sender: Object; e: KeyEventArgs); -begin +procedure SystemOnKeyDown(sender: Object; e: KeyEventArgs) := if OnKeyDown<>nil then OnKeyDown(e.Key); -end; procedure SystemOnKeyUp(sender: Object; e: KeyEventArgs) := if OnKeyUp<>nil then OnKeyUp(e.Key); +procedure SystemOnKeyPress(sender: Object; e: TextCompositionEventArgs) := +begin + if (OnKeyPress<>nil) and (e.Text<>nil) and (e.Text.Length>0) then + OnKeyPress(e.Text[1]); +end; + procedure SystemOnResize(sender: Object; e: SizeChangedEventArgs) := if OnResize<>nil then OnResize(); @@ -1521,6 +1527,7 @@ public MouseMove += SystemOnMouseMove; KeyDown += SystemOnKeyDown; KeyUp += SystemOnKeyUp; + Self.TextInput += SystemOnKeyPress; SizeChanged += SystemOnResize; CompositionTarget.Rendering += RenderFrame; diff --git a/TestSuite/errors/err0305.pas b/TestSuite/errors/err0305.pas new file mode 100644 index 000000000..f3bbfa6be --- /dev/null +++ b/TestSuite/errors/err0305.pas @@ -0,0 +1,9 @@ +type A = class + procedure p1(i: real; Self: integer); + begin + end; +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 cf4f7bc9d..5f5694d7b 100644 --- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs +++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs @@ -13252,6 +13252,17 @@ namespace PascalABCCompiler.TreeConverter } current_function_header = _procedure_header; hard_node_test_and_visit(_procedure_header.name); + + if (!_procedure_header.is_extension() && !(context.top_function is common_namespace_function_node)) + { + var q = _procedure_header.parameters?.params_list?.SelectMany(p => p.idents.idents).Where(id => id.name.ToLower() == "self"); + if (q != null && q.Count() > 0) + { + var sid = q.First(); + AddError(get_location(sid), "SELF_NOT_ALLOWED_IN_METHOD_PARAMS"); + } + } + current_function_header = null; if (context.converted_template_type != null) { diff --git a/bin/Lng/Eng/SemanticErrors_ms.dat b/bin/Lng/Eng/SemanticErrors_ms.dat index 5b1e354f7..9b5e61c7a 100644 --- a/bin/Lng/Eng/SemanticErrors_ms.dat +++ b/bin/Lng/Eng/SemanticErrors_ms.dat @@ -17,4 +17,5 @@ STATIC_PROPERTY_MUST_HAVE_STATIC_ACCESSOR=Static property accessor must be stati ENUMS_CANNOT_BE_GENERIC=Enumerator type cannot be generic PROGRAM_NAME_FOR_TYPE_NAME_IS_PROHIBITED=The name 'program' is prohibited as type name DEFAULT_PARAMS_IN_DELEGATE_TYPE=Procedure type cannot have default parameters -CONSTRUCTOR_CALL_FOR_DELEGATE_TYPES_IS_FORBIDDEN=Constructor call for delegate types is forbidden \ No newline at end of file +CONSTRUCTOR_CALL_FOR_DELEGATE_TYPES_IS_FORBIDDEN=Constructor call for delegate types is forbidden +SELF_NOT_ALLOWED_IN_METHOD_PARAMS=Self is not allowed as method parameter name \ No newline at end of file diff --git a/bin/Lng/Rus/SemanticErrors_ms.dat b/bin/Lng/Rus/SemanticErrors_ms.dat index dcd9dd065..1f1107ec9 100644 --- a/bin/Lng/Rus/SemanticErrors_ms.dat +++ b/bin/Lng/Rus/SemanticErrors_ms.dat @@ -18,4 +18,5 @@ STATIC_PROPERTY_MUST_HAVE_STATIC_ACCESSOR=Акцессор статическо ENUMS_CANNOT_BE_GENERIC=Перечислимый тип не может быть обобщенным PROGRAM_NAME_FOR_TYPE_NAME_IS_PROHIBITED=Имя 'program' запрещено в качестве имени типа DEFAULT_PARAMS_IN_DELEGATE_TYPE=В процедурном типе не могут быть параметры по умолчанию -CONSTRUCTOR_CALL_FOR_DELEGATE_TYPES_IS_FORBIDDEN=Для типов делегатов запрещен вызов конструктора. Вместо этого присвойте делегату имя подпрограммы или имя другого делегата \ No newline at end of file +CONSTRUCTOR_CALL_FOR_DELEGATE_TYPES_IS_FORBIDDEN=Для типов делегатов запрещен вызов конструктора. Вместо этого присвойте делегату имя подпрограммы или имя другого делегата +SELF_NOT_ALLOWED_IN_METHOD_PARAMS=Параметр метода не может иметь имя Self \ No newline at end of file