diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs index 91927b978..5c13e12a1 100644 --- a/Compiler/Compiler.cs +++ b/Compiler/Compiler.cs @@ -2618,7 +2618,6 @@ namespace PascalABCCompiler { if (FileName.IndexOf(Path.DirectorySeparatorChar) != -1) { - File.Copy(Path.Combine(Environment.CurrentDirectory, FileName), Path.Combine(Environment.CurrentDirectory, Path.GetFileName(FileName)), true); if (CompilerOptions.useOutputDirectory) File.Copy(Path.Combine(Environment.CurrentDirectory, FileName), Path.Combine(CompilerOptions.OutputDirectory, Path.GetFileName(FileName)), true); diff --git a/TestSuite/CompilationSamples/PABCSystem.pas b/TestSuite/CompilationSamples/PABCSystem.pas index 6b00332c4..009cc26e3 100644 --- a/TestSuite/CompilationSamples/PABCSystem.pas +++ b/TestSuite/CompilationSamples/PABCSystem.pas @@ -12362,12 +12362,10 @@ begin Result := Self.Split(delim, System.StringSplitOptions.RemoveEmptyEntries); end; -const SpaceDelimiters = ' '+#9#10#13; - -/// Преобразует строку в массив слов, используя в качестве разделителей символы из строки delim -function ToWords(Self: string; delim: string := SpaceDelimiters): array of string; extensionmethod; +/// Преобразует строку в массив слов, используя в качестве разделителей символы из строки delims +function ToWords(Self: string; delims: string := ' '): array of string; extensionmethod; begin - Result := Self.Split(delim.ToCharArray, System.StringSplitOptions.RemoveEmptyEntries); + Result := Self.Split(delims.ToCharArray, System.StringSplitOptions.RemoveEmptyEntries); end; procedure PassSpaces(var s: string; var from: integer); diff --git a/TestSuite/errors/err0390.pas b/TestSuite/errors/err0390.pas new file mode 100644 index 000000000..4bead7f7c --- /dev/null +++ b/TestSuite/errors/err0390.pas @@ -0,0 +1,23 @@ +type + t0 = abstract class end; + + t1 = class + where T: t0; + + procedure p1(x: byte); + begin + var p: Action0 := ()-> + begin + + + Writeln(x); + + Writeln(new T); + + end; + p(); + end; + + end; + +begin end. \ No newline at end of file diff --git a/TestSuite/lambdas_generics8.pas b/TestSuite/lambdas_generics8.pas new file mode 100644 index 000000000..7188bbdb1 --- /dev/null +++ b/TestSuite/lambdas_generics8.pas @@ -0,0 +1,26 @@ +type + t0 = abstract class + end; + + t2 = class(t0) + end; + + t1 = class + where T: t0, constructor; + public obj: T; + procedure p1; + begin + var p: Action0 := ()-> + begin + obj := new T; + end; + p(); + end; + + end; + +begin + var o := new t1; + o.p1; + assert((o.obj <> nil) and (o.obj.GetType = typeof(t2))); +end. \ No newline at end of file diff --git a/TestSuite/lambdas_generics9.pas b/TestSuite/lambdas_generics9.pas new file mode 100644 index 000000000..51b3deb41 --- /dev/null +++ b/TestSuite/lambdas_generics9.pas @@ -0,0 +1,25 @@ +type + t0 = abstract class end; + + t1 = class + where T: t0, constructor; + i: byte; + function MakeT := new T; + + function f1(x: byte): ()->T := ()-> + begin + + i := x; + + Result := MakeT; + end; + + end; + + t2 = class(t0) end; + +begin + var a := new t1; + var obj := a.f1(5)(); + assert(a.i = 5); +end. \ No newline at end of file diff --git a/TreeConverter/LambdaExpressions/Closure/CapturedVariablesSubstitutor.cs b/TreeConverter/LambdaExpressions/Closure/CapturedVariablesSubstitutor.cs index 5955c6f40..e3f56ba72 100644 --- a/TreeConverter/LambdaExpressions/Closure/CapturedVariablesSubstitutor.cs +++ b/TreeConverter/LambdaExpressions/Closure/CapturedVariablesSubstitutor.cs @@ -1113,7 +1113,12 @@ namespace TreeConverter.LambdaExpressions.Closure if (_visitor.context._ctn != null && _visitor.context._ctn.generic_params != null) { - genericParameterEliminations.AddRange(generic_parameter_eliminations.make_eliminations_common(_visitor.context._ctn.generic_params)); + List lst = generic_parameter_eliminations.make_eliminations_common(_visitor.context._ctn.generic_params); + for (int i = 0; i < lst.Count; i++) + if (!lst[i].has_default_ctor && _visitor.context._ctn.generic_params[i] is common_type_node) + lst[i].has_default_ctor = (_visitor.context._ctn.generic_params[i] as common_type_node).has_default_constructor; + genericParameterEliminations.AddRange(lst); + } if (_visitor.context.top_function != null && _visitor.context.top_function.generic_params != null)