Strange bug while concatenating TBytes arrays
## Summary
<!-- Summarize the bug encountered concisely -->
There is a strange issue while concatenating mixture of multiple TBytes variables and constants. The concatenation produces a buggy result.
## System Information
<!-- The more information are provided the easier it is to replicate the bug -->
- **Operating system:** Ubuntu 22.04
- **Processor architecture:** x86-64
- **Compiler version:** 3.2.2
- **Device:** Computer
## Steps to reproduce
<!-- How one can reproduce the issue - this is very important! -->
Cosider **x** and **y** as variables of type **TBytes**. Initiate them as bellow:
```pascal
x := [1, 2, 3, 4, 6, 7, 8];
y := [];
```
Now do the following operation:
```pascal
y := y + [5, x[1]] + copy(x, 3, length(x));
```
We would expect the result as `y = [5, 2, 4, 6, 7, 8]` but what happens is `y = [4, 6, 7, 8, 4, 6, 7, 8]`
## Example Project
<!-- If possible, please create an example project that exhibits the problematic
behavior, and link to it here in the bug report. -->
```pascal
program Project1;
{$mode delphi}
uses
SysUtils;
var
x, y: TBytes;
i: Integer;
begin
x := [1, 2, 3, 4, 6, 7, 8];
y := []; // y = []
y := y + [5, x[1]] + copy(x, 3, length(x)); // y = [5, 2, 4, 6, 7, 8]
for i := 0 to High(y) do begin
// Expected output: 5 2 4 6 7 8
// What was written: 4 6 7 8 4 6 7 8
// ERROR
Write(y[i]: 2);
end;
Writeln;
y := [5, x[1]]; // y = [5, 2]
y := [5, x[1]] + y + copy(x, 3, length(x)); // y = [5, 2, 5, 2, 4, 6, 7, 8]
for i := 0 to High(y) do begin
// Expected output: 5 2 5 2 4 6 7 8
// What was written: 4 6 7 8 5 2 4 6 7 8
// ERROR
Write(y[i]: 2);
end;
Writeln;
y := [5, x[1]]; // y = [5, 2]
y := [5, x[1]] + copy(x, 3, length(x)); // y = [5, 2, 4, 6, 7, 8]
for i := 0 to High(y) do begin
// Expected output: 5 2 4 6 7 8
// What was written: 5 2 4 6 7 8
// Correct
Write(y[i]: 2);
end;
Writeln;
y := [5, x[1]]; // y = [5, 2]
y := x + y + copy(x, 3, length(x)); // y = [1, 2, 3, 4, 6, 7, 8, 5, 2, 4, 6, 7, 8]
for i := 0 to High(y) do begin
// Expected output: 1 2 3 4 6 7 8 5 2 4 6 7 8
// What was written: 1 2 3 4 6 7 8 5 2 4 6 7 8
// Correct
Write(y[i]: 2);
end;
end.
```
## What is the current bug behavior?
<!-- What actually happens -->
In case 1 and 2, the output is wrong, but in case 3 and 4 the output is correct. It seems the concatenation of mixture of multiple (more than 2) preinitialized variables with inplace arrays is the cause of the problem.
## Relevant logs and/or screenshots
<!-- Paste any relevant logs - please use code blocks (```) to format console output, logs, and code, as
it's very hard to read otherwise.
You can also use syntax highlighting for Pascal with: ```pascal the code```
For more information see https://docs.gitlab.com/ee/user/markdown.html -->
Program output:
```text
4 6 7 8 5 2 4 6 7 8
4 6 7 8 4 6 7 8
5 2 4 6 7 8
1 2 3 4 6 7 8 5 2 4 6 7 8
```
## Possible fixes
<!-- If you can, link to the line of code that might be responsible for the problem -->
issue