### Bookstore

 Computer Math and Games in Pascal (preview) Lazarus Handbook

### Author Topic: Internal error 2011010304, a rare one  (Read 1162 times)

#### Fibonacci

• Sr. Member
• Posts: 438
##### Internal error 2011010304, a rare one
« on: February 18, 2024, 01:55:11 am »
I guess this one is a rare one

Code: Pascal  [Select][+][-]
1. {\$modeswitch arrayoperators}
2.
3. var
4.   bools: array of boolean;
5.   bool: boolean;
6.
7. begin
8.   bools += [bool or bool]; // project1.lpr(8,26) Error: Internal error 2011010304
9. end.

#### speter

• Sr. Member
• Posts: 349
##### Re: Internal error 2011010304, a rare one
« Reply #1 on: February 18, 2024, 06:38:06 am »
I don't have an answer, but I tweaked your code (to make sure everything was initialised); and still got the same error.

Not sure if that's helpful though.

Code: Pascal  [Select][+][-]
1. var
2.   bools : array of boolean = (false,true,false,false);
3.   boola: boolean = false;
4.   boolb: boolean = true;
5. begin
6.   bools += [boola or boolb];
7.   . . .

I was trying to work out whether the problem was because you were comparing the same data...

I should also comment that I haven't encountered
{\$modeswitch arrayoperators}
before! It sounds cool though.

If i replace the "bools +="  line with:
Code: Pascal  [Select][+][-]
1.   n := length(bools);
2.   setlength(bools,n+1);
3.   bools[n] := boola or boola;
(where n:integer;)
It runs correctly.

cheers
S.
I climbed mighty mountains, and saw that they were actually tiny foothills.

#### Fibonacci

• Sr. Member
• Posts: 438
##### Re: Internal error 2011010304, a rare one
« Reply #2 on: February 18, 2024, 06:49:20 am »
Another example, closer to what my code looked like when I first encountered this internal error.

Code: Pascal  [Select][+][-]
1. {\$modeswitch arrayoperators}
2.
3. var
4.   bools: array of boolean;
5.   s: string;
6.
7. begin
8.   bools := []; // init
9.   bools += [(s <> '') and (s[1] = 'x')]; // project1.lpr(9,40) Error: Internal error 2011010304
10. end.

Inserting a new value that is expression of 2 bools (or more) accessing variables or functions = internal error.

I created an issue on gitlab, and have feeling it will be fixed soon.

#### speter

• Sr. Member
• Posts: 349
##### Re: Internal error 2011010304, a rare one
« Reply #3 on: February 18, 2024, 06:50:32 am »
The manual (https://www.freepascal.org/docs-html/ref/refsu48.html) example for Dynamic array operators is:
Code: Pascal  [Select][+][-]
1. var
2.   a,b, c : array of byte;
3. begin
4.   a:=[0,1,2];
5.   b:=[3,4,5];
6.   c:=a+b;

So your code (I tihnk) has 2 possible issues:
+ you aren't adding 2 dynamic arrays; and
+ you are using the short-cut syntax +=

Having said all that, I agree with you!
This is a strange response.

cheers
S.
I climbed mighty mountains, and saw that they were actually tiny foothills.

#### speter

• Sr. Member
• Posts: 349
##### Re: Internal error 2011010304, a rare one
« Reply #4 on: February 18, 2024, 06:58:33 am »
Interestingly, this works fine:
Code: Pascal  [Select][+][-]
1. var
2.   bools : array of boolean = (false,true,false,false);
3.   boolb : array of boolean = ();
4.   s : string = 'foo';
5. begin
6.   boolb := [s[1]='f'];
7.   bools += bools + boolb;

EDIT: changing the last line to
Code: Pascal  [Select][+][-]
1.   bools += boolb;
also worked fine!

cheers
S.
« Last Edit: February 18, 2024, 07:02:56 am by speter »
I climbed mighty mountains, and saw that they were actually tiny foothills.

#### PascalDragon

• Hero Member
• Posts: 5519
• Compiler Developer
##### Re: Internal error 2011010304, a rare one
« Reply #5 on: February 18, 2024, 01:30:56 pm »
I guess this one is a rare one

Code: Pascal  [Select][+][-]
1. {\$modeswitch arrayoperators}
2.
3. var
4.   bools: array of boolean;
5.   bool: boolean;
6.
7. begin
8.   bools += [bool or bool]; // project1.lpr(8,26) Error: Internal error 2011010304
9. end.

#### Fibonacci

• Sr. Member
• Posts: 438
##### Re: Internal error 2011010304, a rare one
« Reply #6 on: February 18, 2024, 01:33:30 pm »

#### PascalDragon

• Hero Member
• Posts: 5519
• Compiler Developer
##### Re: Internal error 2011010304, a rare one
« Reply #7 on: February 18, 2024, 02:16:28 pm »

#### Joanna

• Hero Member
• Posts: 807
##### Re: Internal error 2011010304, a rare one
« Reply #8 on: February 18, 2024, 11:43:34 pm »
I always thought that it was necessary to set length of dynamic array before trying to use it? Since when has it been possible to add things to an array like It’s a string?
✨ 🙋🏻‍♀️ More Pascal enthusiasts are needed on IRC .. https://libera.chat/guides/ IRC.LIBERA.CHAT  Ports [6667 plaintext ] or [6697 secure] channel #fpc  Please private Message me if you have any questions or need assistance. 💁🏻‍♀️

#### speter

• Sr. Member
• Posts: 349
##### Re: Internal error 2011010304, a rare one
« Reply #9 on: February 19, 2024, 12:28:49 am »
I always thought that it was necessary to set length of dynamic array before trying to use it? Since when has it been possible to add things to an array like It’s a string?

cheers
S.
I climbed mighty mountains, and saw that they were actually tiny foothills.