From cd1585fead29e781cfaa49126f6dda80705f94b0 Mon Sep 17 00:00:00 2001 From: Ivan Bondarev Date: Tue, 5 Jan 2021 10:45:39 +0100 Subject: [PATCH] #2377 sample 1 --- TestSuite/records19.pas | 21 +++++++++++++++++++ .../TreeConversion/compilation_context.cs | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 TestSuite/records19.pas diff --git a/TestSuite/records19.pas b/TestSuite/records19.pas new file mode 100644 index 000000000..ebcfe6537 --- /dev/null +++ b/TestSuite/records19.pas @@ -0,0 +1,21 @@ +var i: integer; + +type + r1 = record + public function InitI1:integer; + begin + Result := 1; + Inc(i); + end; + + public i1: integer := InitI1; + public i2: integer; + + end; + +function f1 := default(r1); + +begin + var a := f1; + assert(i = 1); +end. \ No newline at end of file diff --git a/TreeConverter/TreeConversion/compilation_context.cs b/TreeConverter/TreeConversion/compilation_context.cs index c51bd5ff8..b6e1e986d 100644 --- a/TreeConverter/TreeConversion/compilation_context.cs +++ b/TreeConverter/TreeConversion/compilation_context.cs @@ -2129,7 +2129,7 @@ namespace PascalABCCompiler.TreeConverter { lbvr.type = SystemLibrary.SystemLibInitializer.TypedSetType.sym_info as type_node; } - if (vdn.type.is_value_type && userInitalValue is common_constructor_call) + if (vdn.type.is_value_type /*&& userInitalValue is common_constructor_call*/) { return new default_operator_node(vdn.type, lid); }