From ff55c29feeecaacb2e8110a56559d923e7821e71 Mon Sep 17 00:00:00 2001 From: Ivan Bondarev Date: Mon, 5 Apr 2021 14:39:02 +0200 Subject: [PATCH] #1554 --- TestSuite/classconst3.pas | 11 +++++++++++ TreeConverter/TreeConversion/syntax_tree_visitor.cs | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 TestSuite/classconst3.pas diff --git a/TestSuite/classconst3.pas b/TestSuite/classconst3.pas new file mode 100644 index 000000000..8e7c32e49 --- /dev/null +++ b/TestSuite/classconst3.pas @@ -0,0 +1,11 @@ +type + TClass = class + public const b: array of string = ('abc','def'); + public const s: string = 'tt'; + end; + +begin + assert(TClass.b[0] = 'abc'); + assert(TClass.b[1] = 'def'); + assert(TClass.s = 'tt'); +end. \ No newline at end of file diff --git a/TreeConverter/TreeConversion/syntax_tree_visitor.cs b/TreeConverter/TreeConversion/syntax_tree_visitor.cs index c55f7b300..6e32ab230 100644 --- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs +++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs @@ -11474,7 +11474,7 @@ namespace PascalABCCompiler.TreeConverter cdn.const_value = convert_strong_to_constant_node(_typed_const_definition.const_value, tn); const_def_type = null; is_typed_const_def = false; - if (cdn is class_constant_definition && cdn.constant_value.value == null) + if (cdn is class_constant_definition && (cdn.constant_value.value == null && !(cdn.constant_value is array_const))) AddError(new NotSupportedError(cons_loc)); }