Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2012-11

Tests in Delphi XE3 regarding Type Helpers

8 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Sven Barth

Hello together!

Could someone with access to Delphi XE3 please compile and run the attached tests and provide me with the output of the test or (in case of an error) with the output of the compiler?
The tthlperrX.pas tests should not compile, so here I'd like to get the error messages.
The other tests should compile, so please try to adjust them until they do and report me any adjustments you made. If you can't get them to compile then please report me the errors you get with the initial test file.

Thank you.

Regards,
Sven

Reply by email

Marco van de Voort
to Sven Barth

In our previous episode, Sven Barth said:

Show quoted text 9 lines
Could someone with access to Delphi XE3 please compile and run the attached tests and provide me with the output of the test or (in case of an error) with the output of the compiler? The tthlperrX.pas tests should not compile, so here I'd like to get the error messages. The other tests should compile, so please try to adjust them until they do and report me any adjustments you made. If you can't get them to compile then please report me the errors you get with the initial test file.

D:\testing\rechelp>dcc32 tthlperr1.pas
Embarcadero Delphi for Win32 compiler version 24.0 Copyright (c) 1983,2012 Embarcadero Technologies, Inc. tthlperr1.pas(4) Error: E2018 Record, object or class type required tthlperr1.pas(6)

D:\testing\rechelp>dcc32 tthlperr2.pas
Embarcadero Delphi for Win32 compiler version 24.0 Copyright (c) 1983,2012 Embarcadero Technologies, Inc. tthlperr2.pas(14) Error: E2018 Record, object or class type required tthlperr2.pas(15) Error: E2018 Record, object or class type required tthlperr2.pas(17)

D:\testing\rechelp>dcc32 tthlpminus.pas
Embarcadero Delphi for Win32 compiler version 24.0 Copyright (c) 1983,2012 Embarcadero Technologies, Inc. tthlpminus.pas(14) Error: E2018 Record, object or class type required tthlpminus.pas(15) Error: E2018 Record, object or class type required tthlpminus.pas(17)

1. Typecasting the "42" literals to integer works
2. changing record helper type to "int64" doesn't.
3. Changing to smaller types (int8,int16) doesn't help.
4. changing to uint8 works for the "42" one, not for the "-42" one.

D:\testing\rechelp>dcc32 tthlpself.pas
Embarcadero Delphi for Win32 compiler version 24.0 Copyright (c) 1983,2012 Embarcadero Technologies, Inc. tthlpself.pas(36)
37 lines, 0.09 seconds, 18816 bytes code, 13240 bytes data.

D:\testing\rechelp>tthlpself
-> throws RTE 105

D:\testing\rechelp>dcc32 tthlpsize.pas
Embarcadero Delphi for Win32 compiler version 24.0 Copyright (c) 1983,2012 Embarcadero Technologies, Inc. tthlpsize.pas(24) Error: E2003 Undeclared identifier: 'Short' tthlpsize.pas(78) Error: E2015 Operator not applicable to this operand type tthlpsize.pas(80) Error: E2015 Operator not applicable to this operand type tthlpsize.pas(82) Error: E2015 Operator not applicable to this operand type tthlpsize.pas(84) Error: E2015 Operator not applicable to this operand type tthlpsize.pas(87)

The first is easily fixable by changing short (which probably should have been shortint) to int16.

The remaining errors are the negative values. I didn't find a solution for them with tthlpminus

Reply by email

Sven Barth
to Marco van de Voort
Marco van de Voort wrote 21 lines
In our previous episode, Sven Barth said: > Could someone with access to Delphi XE3 please compile and run the > attached tests and provide me with the output of the test or (in case of > an error) with the output of the compiler? > The tthlperrX.pas tests should not compile, so here I'd like to get the > error messages. > The other tests should compile, so please try to adjust them until they > do and report me any adjustments you made. If you can't get them to > compile then please report me the errors you get with the initial test file. D:\testing\rechelp>dcc32 tthlperr1.pas Embarcadero Delphi for Win32 compiler version 24.0 Copyright (c) 1983,2012 Embarcadero Technologies, Inc. tthlperr1.pas(4) Error: E2018 Record, object or class type required tthlperr1.pas(6) D:\testing\rechelp>dcc32 tthlperr2.pas Embarcadero Delphi for Win32 compiler version 24.0 Copyright (c) 1983,2012 Embarcadero Technologies, Inc. tthlperr2.pas(14) Error: E2018 Record, object or class type required tthlperr2.pas(15) Error: E2018 Record, object or class type required tthlperr2.pas(17)

Ok, the error for tthlperr1.pas was expected (though I was curious what the error message would be).
For tthlperr2.pas it would have been interesting to see if the same error is reported if a helper is in scope, but the method is invalid... could you please repeat that test with a string helper and a string constant? Or change the type of the int helper to "uint8" which seems to have helped in the tthlpsize.pas test...

Show quoted text 11 lines
D:\testing\rechelp>dcc32 tthlpminus.pas Embarcadero Delphi for Win32 compiler version 24.0 Copyright (c) 1983,2012 Embarcadero Technologies, Inc. tthlpminus.pas(14) Error: E2018 Record, object or class type required tthlpminus.pas(15) Error: E2018 Record, object or class type required tthlpminus.pas(17) 1. Typecasting the "42" literals to integer works 2. changing record helper type to "int64" doesn't. 3. Changing to smaller types (int8,int16) doesn't help. 4. changing to uint8 works for the "42" one, not for the "-42" one.

Ok... so Delphi does use the minimum required size for the constant. Good. Does "int8" help for the "-42"? What if you change it to "(-42).DoTest"?

Show quoted text 8 lines
D:\testing\rechelp>dcc32 tthlpself.pas Embarcadero Delphi for Win32 compiler version 24.0 Copyright (c) 1983,2012 Embarcadero Technologies, Inc. tthlpself.pas(36) 37 lines, 0.09 seconds, 18816 bytes code, 13240 bytes data. D:\testing\rechelp>tthlpself -> throws RTE 105

It seems that I forgot a "{$apptype console}" :)

Show quoted text 13 lines
D:\testing\rechelp>dcc32 tthlpsize.pas Embarcadero Delphi for Win32 compiler version 24.0 Copyright (c) 1983,2012 Embarcadero Technologies, Inc. tthlpsize.pas(24) Error: E2003 Undeclared identifier: 'Short' tthlpsize.pas(78) Error: E2015 Operator not applicable to this operand type tthlpsize.pas(80) Error: E2015 Operator not applicable to this operand type tthlpsize.pas(82) Error: E2015 Operator not applicable to this operand type tthlpsize.pas(84) Error: E2015 Operator not applicable to this operand type tthlpsize.pas(87) The first is easily fixable by changing short (which probably should have been shortint) to int16.

The introduction of the (U)IntXX types was one of the best things I remember (and luckily we already have them in FPC as well :) ), as I always forget how the smaller types are named... -.-

The remaining errors are the negative values. I didn't find a solution for them with tthlpminus

So the hexadecimal values work correctly? What if you here also try the suggestion "(negativevalue).DoTest"? You might also want to add a "{$apptype console}" here.

Otherwise: Thank you so far. :)

Regards,
Sven

Reply by email

Marco van de Voort
to Sven Barth

In our previous episode, Sven Barth said:

For tthlperr2.pas it would have been interesting to see if the same error is reported if a helper is in scope, but the method is invalid... could you please repeat that test with a string helper and a string constant?

tthlperr2.pas(15) Error: E2003 Undeclared identifier: 'DoTest2'

Or change the type of the int helper to "uint8" which seems to have helped in the tthlpsize.pas test...

Only for unsigned constants. I tried, and the results are the same dotest2.

Even with the unsigned value. Only if I change dotest2 to dotest1 I get the operator not applicable. So somehow the method name has prio over the literal type mismatch

Show quoted text 12 lines
> D:\testing\rechelp>dcc32 tthlpminus.pas > Embarcadero Delphi for Win32 compiler version 24.0 > Copyright (c) 1983,2012 Embarcadero Technologies, Inc. > tthlpminus.pas(14) Error: E2018 Record, object or class type required > tthlpminus.pas(15) Error: E2018 Record, object or class type required > tthlpminus.pas(17) > > 1. Typecasting the "42" literals to integer works > 2. changing record helper type to "int64" doesn't. > 3. Changing to smaller types (int8,int16) doesn't help. > 4. changing to uint8 works for the "42" one, not for the "-42" one. Ok... so Delphi does use the minimum required size for the constant.

For unsigned ones yes.

Good. Does "int8" help for the "-42"? What if you change it to "(-42).DoTest"?

Then it passes for the signed (int8) type. So it seems there is no helper that will accept both positive and negative literals.

Show quoted text 10 lines
> D:\testing\rechelp>dcc32 tthlpself.pas > Embarcadero Delphi for Win32 compiler version 24.0 > Copyright (c) 1983,2012 Embarcadero Technologies, Inc. > tthlpself.pas(36) > 37 lines, 0.09 seconds, 18816 bytes code, 13240 bytes data. > > D:\testing\rechelp>tthlpself > -> throws RTE 105 It seems that I forgot a "{$apptype console}" :)

42
21
Type Helper
Hello Type Helper World

Show quoted text 15 lines
> D:\testing\rechelp>dcc32 tthlpsize.pas > Embarcadero Delphi for Win32 compiler version 24.0 > Copyright (c) 1983,2012 Embarcadero Technologies, Inc. > tthlpsize.pas(24) Error: E2003 Undeclared identifier: 'Short' > tthlpsize.pas(78) Error: E2015 Operator not applicable to this operand type > tthlpsize.pas(80) Error: E2015 Operator not applicable to this operand type > tthlpsize.pas(82) Error: E2015 Operator not applicable to this operand type > tthlpsize.pas(84) Error: E2015 Operator not applicable to this operand type > tthlpsize.pas(87) > > The first is easily fixable by changing short (which probably should have > been shortint) to int16. The introduction of the (U)IntXX types was one of the best things I remember (and luckily we already have them in FPC as well :) ), as I always forget how the smaller types are named... -.-

Why do you think I added them when I found out? :-) I never could either. (specially smallint and shortint)

> The remaining errors are the negative values. I didn't find a solution for > them with tthlpminus So the hexadecimal values work correctly?

Yes

What if you here also try the suggestion "(negativevalue).DoTest"? You might also want to add a "{$apptype console}" here.

Strange results. All compile except (-1)

Input:

 Writeln(0, #9, 0.DoTest);
//  Writeln(-1, #9, (-1).DoTest);
  Writeln($ABCD, #9, $ABCD.DoTest);
  Writeln(-32987, #9, (-32987).DoTest);
  Writeln(2345678, #9, 2345678.DoTest);
  Writeln(-2345678, #9, (-2345678).DoTest);
  Writeln($1234567887654321, #9, $1234567887654321.DoTest);
  Writeln(-9876543211234, #9, (-9876543211234).DoTest);
  Writeln(9876543211234, #9, 9876543211234.DoTest);

Output:

0 Byte
43981 Word
-32987 LongInt
2345678 LongInt
-2345678 LongInt
1311768467139281697 Int64
-9876543211234 Int64
9876543211234 Int64

... which seems to have a bias for signed types that I didn't see in earlier tests.

I played a bit with the minus one value, and got an IE:

Writeln(-129, #9, (-129).DoTest);

caused:

D:\testing\rechelp>dcc32 tthlpsize.pas
Embarcadero Delphi for Win32 compiler version 24.0 Copyright (c) 1983,2012 Embarcadero Technologies, Inc. tthlpsize.pas(78) Fatal: F2084 Internal Error: SY3502

Otherwise: Thank you so far. :)

As soon as it is finished, you go back to generics? :-)

Reply by email

Marco van de Voort
to Marco van de Voort

In our previous episode, Marco van de Voort said:

I was still playing, and decided to replace smallinthelper with "int8" instead of smallint or whatever. That suddenly made small (-1,-2) values compile.

The range -129 .. -32768 though gives the IE.

Strangely, the testresult is

-10 SmallInt

Reply by email

Sven Barth
to Marco van de Voort: In our previous episode, Sven Barth said: tthlperr2.pas(15) Error: E2003 Undeclared…
Marco van de Voort wrote 6 lines
In our previous episode, Sven Barth said: > For tthlperr2.pas it would have been interesting to see if the same > error is reported if a helper is in scope, but the method is invalid... > could you please repeat that test with a string helper and a string > constant? tthlperr2.pas(15) Error: E2003 Undeclared identifier: 'DoTest2'

Somehow what I hoped for. :)

Show quoted text 26 lines
> Or change the type of the int helper to "uint8" which seems to > have helped in the tthlpsize.pas test... Only for unsigned constants. I tried, and the results are the same dotest2. Even with the unsigned value. Only if I change dotest2 to dotest1 I get the operator not applicable. So somehow the method name has prio over the literal type mismatch >> D:\testing\rechelp>dcc32 tthlpminus.pas >> Embarcadero Delphi for Win32 compiler version 24.0 >> Copyright (c) 1983,2012 Embarcadero Technologies, Inc. >> tthlpminus.pas(14) Error: E2018 Record, object or class type required >> tthlpminus.pas(15) Error: E2018 Record, object or class type required >> tthlpminus.pas(17) >> >> 1. Typecasting the "42" literals to integer works >> 2. changing record helper type to "int64" doesn't. >> 3. Changing to smaller types (int8,int16) doesn't help. >> 4. changing to uint8 works for the "42" one, not for the "-42" one. > Ok... so Delphi does use the minimum required size for the constant. For unsigned ones yes. > Good. Does "int8" help for the "-42"? What if you change it to > "(-42).DoTest"? Then it passes for the signed (int8) type. So it seems there is no helper that will accept both positive and negative literals.

Yes, that's true, but at least one can get negative literals passed to a helper...

Show quoted text 13 lines
>> D:\testing\rechelp>dcc32 tthlpself.pas >> Embarcadero Delphi for Win32 compiler version 24.0 >> Copyright (c) 1983,2012 Embarcadero Technologies, Inc. >> tthlpself.pas(36) >> 37 lines, 0.09 seconds, 18816 bytes code, 13240 bytes data. >> >> D:\testing\rechelp>tthlpself >> -> throws RTE 105 > It seems that I forgot a "{$apptype console}" :) 42 21 Type Helper Hello Type Helper World

Great... this does not make that feature easier to implement -.-

Show quoted text 65 lines
>> D:\testing\rechelp>dcc32 tthlpsize.pas >> Embarcadero Delphi for Win32 compiler version 24.0 >> Copyright (c) 1983,2012 Embarcadero Technologies, Inc. >> tthlpsize.pas(24) Error: E2003 Undeclared identifier: 'Short' >> tthlpsize.pas(78) Error: E2015 Operator not applicable to this operand type >> tthlpsize.pas(80) Error: E2015 Operator not applicable to this operand type >> tthlpsize.pas(82) Error: E2015 Operator not applicable to this operand type >> tthlpsize.pas(84) Error: E2015 Operator not applicable to this operand type >> tthlpsize.pas(87) >> >> The first is easily fixable by changing short (which probably should have >> been shortint) to int16. > The introduction of the (U)IntXX types was one of the best things I > remember (and luckily we already have them in FPC as well :) ), as I > always forget how the smaller types are named... -.- Why do you think I added them when I found out? :-) I never could either. (specially smallint and shortint) >> The remaining errors are the negative values. I didn't find a solution for >> them with tthlpminus > So the hexadecimal values work correctly? Yes > What if you here also try the > suggestion "(negativevalue).DoTest"? You might also want to add a > "{$apptype console}" here. Strange results. All compile except (-1) Input: Writeln(0, #9, 0.DoTest); // Writeln(-1, #9, (-1).DoTest); Writeln($ABCD, #9, $ABCD.DoTest); Writeln(-32987, #9, (-32987).DoTest); Writeln(2345678, #9, 2345678.DoTest); Writeln(-2345678, #9, (-2345678).DoTest); Writeln($1234567887654321, #9, $1234567887654321.DoTest); Writeln(-9876543211234, #9, (-9876543211234).DoTest); Writeln(9876543211234, #9, 9876543211234.DoTest); Output: 0 Byte 43981 Word -32987 LongInt 2345678 LongInt -2345678 LongInt 1311768467139281697 Int64 -9876543211234 Int64 9876543211234 Int64 ... which seems to have a bias for signed types that I didn't see in earlier tests. I played a bit with the minus one value, and got an IE: Writeln(-129, #9, (-129).DoTest); caused: D:\testing\rechelp>dcc32 tthlpsize.pas Embarcadero Delphi for Win32 compiler version 24.0 Copyright (c) 1983,2012 Embarcadero Technologies, Inc. tthlpsize.pas(78) Fatal: F2084 Internal Error: SY3502

Fascinating results... Thank you! :D

> Otherwise: Thank you so far. :) As soon as it is finished, you go back to generics? :-)

I don't know yet what I'll finish first (this was just some preparation), but I do hope that I'll get to decreasing my "feature list" in the next weeks :D (and yes, this includes generics)

Regards,
Sven

Reply by email

Marco van de Voort
to Sven Barth

In our previous episode, Sven Barth said:

Show quoted text 5 lines
> D:\testing\rechelp>dcc32 tthlpsize.pas > Embarcadero Delphi for Win32 compiler version 24.0 > Copyright (c) 1983,2012 Embarcadero Technologies, Inc. > tthlpsize.pas(78) Fatal: F2084 Internal Error: SY3502 Fascinating results... Thank you! :D

QC #110917

Show quoted text 6 lines
>> Otherwise: Thank you so far. :) > As soon as it is finished, you go back to generics? :-) > I don't know yet what I'll finish first (this was just some preparation), but I do hope that I'll get to decreasing my "feature list" in the next weeks :D (and yes, this includes generics)

I was just teasing.

Reply by email

Sven Barth
to Marco van de Voort
Marco van de Voort wrote 7 lines
>>> Otherwise: Thank you so far. :) >> As soon as it is finished, you go back to generics? :-) >> > I don't know yet what I'll finish first (this was just some > preparation), but I do hope that I'll get to decreasing my "feature > list" in the next weeks :D (and yes, this includes generics) I was just teasing.

You might only have been teasing, but there are features on my list that I wait for to use for quite some time already :)

Regards,
Sven

Reply by email