diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index c9a5531fd..80484afb7 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 = "1"; public const string Build = "0"; - public const string Revision = "1172"; + public const string Revision = "1173"; 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 b81e0240f..89d0d34d3 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ -%MINOR%=1 -%REVISION%=1172 %COREVERSION%=0 +%REVISION%=1173 +%MINOR%=1 %MAJOR%=3 diff --git a/Localization/DefaultLang.resources b/Localization/DefaultLang.resources index efd34e690..9323db95f 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 5f229d782..2512bb1c6 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.1.0.1172' +!define VERSION '3.1.0.1173' diff --git a/TestSuite/foreachvar1.pas b/TestSuite/foreachvar1.pas new file mode 100644 index 000000000..18fae17f9 --- /dev/null +++ b/TestSuite/foreachvar1.pas @@ -0,0 +1,17 @@ +{begin + var s := [1,2,3]; + foreach var x in s do + begin + var y := x + x; + end; +end.} +type + TPair = auto class + Key: string; + Value: integer; + end; +begin + var A := Arr(new TPair('a',3),new TPair('c',1),new TPair('b',4)); + foreach var p in A do + writeln(p.Key, '->', p.Value); +end. \ No newline at end of file diff --git a/TestSuite/foreachvar2.pas b/TestSuite/foreachvar2.pas new file mode 100644 index 000000000..62233f3a5 --- /dev/null +++ b/TestSuite/foreachvar2.pas @@ -0,0 +1,7 @@ +begin + var s := [1,2,3]; + foreach var x in s do + begin + var y := x + x; + end; +end. diff --git a/TreeConverter/TreeConversion/syntax_tree_visitor.cs b/TreeConverter/TreeConversion/syntax_tree_visitor.cs index 215724991..d589cb36f 100644 --- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs +++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs @@ -16179,6 +16179,7 @@ namespace PascalABCCompiler.TreeConverter // IEnumerable, Range(1,10), Dictionary: tn = compiled_type_node // IEnumerable: tn = compiled_generic_instance_type_node // FibGen = class(IEnumerable,IEnumerator): tn = common_type_node, en = compiled_type_node + // array of Person: tn = common_type_node { System.Type ct; if (tn is compiled_type_node) @@ -16198,7 +16199,7 @@ namespace PascalABCCompiler.TreeConverter r = ct.GetInterface(IEnTstring); if (r != null) { - Type arg1 = r.GetGenericArguments().First(); + Type arg1 = r.GetGenericArguments().First(); // тип параметра IEnumerable var str = arg1.GetGenericArguments().Count(); if (tn is compiled_type_node) { @@ -16230,7 +16231,7 @@ namespace PascalABCCompiler.TreeConverter } else { - if (tn.element_type != null) // значит, это массив любой размерности - 02.02.16 SSM + if (tn.element_type != null) // значит, это массив любой размерности - 02.02.16 SSM - еще может быть множество set of T - 22.02.16 SSM { elem_type = tn.element_type; return true; @@ -16265,6 +16266,27 @@ namespace PascalABCCompiler.TreeConverter { if (tn == null || tn is null_type_node || tn.ImplementingInterfaces == null) return false; + + if (tn.element_type != null) // еще может быть множество set of T - 22.02.16 SSM + { + elem_type = tn.element_type; + return true; + } + + foreach (SemanticTree.ITypeNode itn in tn.ImplementingInterfaces) // Ищем интерфейс IEnumerable и возвращаем T в качестве elem_type + { + if (itn is compiled_generic_instance_type_node) + { + var itnc = (itn as compiled_generic_instance_type_node); + var tt = (itnc.original_generic as compiled_type_node).compiled_type; + if (tt == typeof(System.Collections.Generic.IEnumerable<>)) + { + elem_type = itnc.generic_parameters[0] as common_type_node; + return true; + } + } + } + foreach (SemanticTree.ITypeNode itn in tn.ImplementingInterfaces) { //if (itn == ctn) diff --git a/bin/Lib/PABCRtl.dll b/bin/Lib/PABCRtl.dll index e9a306579..2e2e71f5c 100644 Binary files a/bin/Lib/PABCRtl.dll and b/bin/Lib/PABCRtl.dll differ