From 5c4b3f1de42daa9b30291c0f911a769ab53660a6 Mon Sep 17 00:00:00 2001 From: Ivan Bondarev Date: Sat, 4 Nov 2023 12:52:51 +0100 Subject: [PATCH] #2915 --- NETGenerator/NETGenerator.cs | 1 + TestSuite/double_question6.pas | 17 +++++++++++++++++ TestSuite/double_question7.pas | 9 +++++++++ 3 files changed, 27 insertions(+) create mode 100644 TestSuite/double_question6.pas create mode 100644 TestSuite/double_question7.pas diff --git a/NETGenerator/NETGenerator.cs b/NETGenerator/NETGenerator.cs index 857519918..910bf746f 100644 --- a/NETGenerator/NETGenerator.cs +++ b/NETGenerator/NETGenerator.cs @@ -7614,6 +7614,7 @@ namespace PascalABCCompiler.NETGenerator && !(value.obj is ICommonConstructorCall) && !(value.obj is ICommonNamespaceFunctionCallNode) && !(value.obj is ICommonNestedInFunctionFunctionCallNode) && !(value.obj is IQuestionColonExpressionNode) + && !(value.obj is IDoubleQuestionColonExpressionNode) && !(value.obj.conversion_type != null && !value.obj.conversion_type.is_value_type)) { LocalBuilder lb = il.DeclareLocal(helper.GetTypeReference(value.obj.type).tp); diff --git a/TestSuite/double_question6.pas b/TestSuite/double_question6.pas new file mode 100644 index 000000000..a18f27741 --- /dev/null +++ b/TestSuite/double_question6.pas @@ -0,0 +1,17 @@ +type + r1 = record + x: integer; + constructor(x: integer) := self.x := x; + end; + +function f0 := new r1($12345678); + +function f1(n: r1?) := (n??f0).Value; + +begin + // Выводит 0 вместо 12345678 + assert(f1(nil).x.ToString('X') = '12345678'); + var rec: r1; + rec.x := 4; + assert(f1(rec).x.ToString('X') = '4'); +end. \ No newline at end of file diff --git a/TestSuite/double_question7.pas b/TestSuite/double_question7.pas new file mode 100644 index 000000000..6c9185f4a --- /dev/null +++ b/TestSuite/double_question7.pas @@ -0,0 +1,9 @@ + +function f0 := $12345678; + +function f1(n: integer?) := (n??f0).Value; + +begin + // Выводит 0 вместо 12345678 + assert(f1(nil).ToString('X') = '12345678'); +end. \ No newline at end of file