From 8eb2cea3494b684c5e5591e12b98511636ad1353 Mon Sep 17 00:00:00 2001 From: florian Date: Thu, 23 Jun 2022 23:10:48 +0200 Subject: [PATCH] * do not throw an internal error if slice is used on dyn. array paramters, resolves #39806 --- compiler/ninl.pas | 4 +++- tests/webtbf/tw39806.pp | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 tests/webtbf/tw39806.pp diff --git a/compiler/ninl.pas b/compiler/ninl.pas index 616f108511..a44bb76e09 100644 --- a/compiler/ninl.pas +++ b/compiler/ninl.pas @@ -4179,7 +4179,9 @@ implementation end; in_slice_x: - internalerror(2005101502); + { slice can be used only in calls for open array parameters, so it has to be converted appropriatly before + if we get here, the array could not be passed to an open array parameter so it is an error } + CGMessagePos(left.fileinfo,type_e_mismatch); in_ord_x, in_chr_byte: diff --git a/tests/webtbf/tw39806.pp b/tests/webtbf/tw39806.pp new file mode 100644 index 0000000000..a5067ac44e --- /dev/null +++ b/tests/webtbf/tw39806.pp @@ -0,0 +1,18 @@ +{ %fail } +program test; + +type + TByteDynArr = array of byte; + +procedure proc(a: TByteDynArr); +begin + Writeln(Length(a)); +end; + +var + x: array of byte; +begin + x:= [1,2,3,4]; + proc(Slice(x, 2)); + // (15,19) Fatal: Internal error 2005101501 +end.