From 3b7bf665ef1cbfd6b5aa12774a4992e05e22c31b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D0=BE=D0=BD=D0=B4=D0=B0=D1=80=D0=B5=D0=B2=20=D0=98?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD?= Date: Sun, 22 Dec 2019 12:34:07 +0100 Subject: [PATCH] bug fix #2160 --- TestSuite/defaultparams3.pas | 6 ++++++ .../TreeConversion/convertion_data_and_alghoritms.cs | 6 ++++++ TreeConverter/TreeRealization/types.cs | 2 ++ 3 files changed, 14 insertions(+) create mode 100644 TestSuite/defaultparams3.pas diff --git a/TestSuite/defaultparams3.pas b/TestSuite/defaultparams3.pas new file mode 100644 index 000000000..e5cd92556 --- /dev/null +++ b/TestSuite/defaultparams3.pas @@ -0,0 +1,6 @@ +function f1(x: byte := 1) := x; + +begin + var s := $'{f1}'; + assert(s = '1'); +end. \ No newline at end of file diff --git a/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs b/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs index 916ec004c..f9619f8e6 100644 --- a/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs +++ b/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs @@ -2156,6 +2156,12 @@ namespace PascalABCCompiler.TreeConverter // Потому что не учитывается вызов - в вызове может быть функция!! delete_greater_functions(set_of_possible_functions,tcll); // SSM 06/06/19 refactoring + if (set_of_possible_functions.Count == 1) + { + check_single_possible_convertion(loc, tcll[0]); + convert_function_call_expressions(set_of_possible_functions[0], parameters, tcll[0]); + return set_of_possible_functions[0]; + } //Тупая заглушка для примитивных типов. иначе не работает +=, у нас лишком много неявных приведений //в дальнейшем может вызвать странное поведение, это надо проверить if (set_of_possible_functions.Count == 2 && indefinits.Count == 0) diff --git a/TreeConverter/TreeRealization/types.cs b/TreeConverter/TreeRealization/types.cs index ccb844ab8..954ff4fa1 100644 --- a/TreeConverter/TreeRealization/types.cs +++ b/TreeConverter/TreeRealization/types.cs @@ -4443,6 +4443,7 @@ namespace PascalABCCompiler.TreeRealization || fn.simple_function_node is compiled_function_node && (fn.simple_function_node as compiled_function_node).ConnectedToType != null) && fn.simple_function_node.parameters.Count == 2 && fn.simple_function_node.parameters[1].default_value != null) { + int param_num = (fn.simple_function_node is common_namespace_function_node && (fn.simple_function_node as common_namespace_function_node).ConnectedToType != null || fn.simple_function_node is compiled_function_node && (fn.simple_function_node as compiled_function_node).ConnectedToType != null) ? 1 : 0; base_function_call copy_fn = null; if (fn.simple_function_node.return_value_type == ctn) @@ -4457,6 +4458,7 @@ namespace PascalABCCompiler.TreeRealization { continue; } + //TODO: Очень внимательно рассмотреть. Если преобразование типов должно идти через compile_time_executor. possible_type_convertions ptc = type_table.get_convertions(fn.simple_function_node.return_value_type, ctn); if ((ptc.first == null) || (ptc.first.convertion_method == null))