Re: [fpc-pascal] Two possible generics bugs
Am 29.11.2019 um 22:56 schrieb Ryan Joseph via fpc-pascal: On Nov 29, 2019, at 2:00 AM, Sven Barth via fpc-pascal wrote: Why? It does say that a class type is expected. And the column of the error should point to the correct location. That's the same error you'd get when specializing outside of a generic with a non-class type. I think you're right, my fault for not looking at the column close enough. The "specialize" is part of the generic identifier, so it must be "FGL.specialize TFPGObjectList". That said however an internal error should not happen (especially the one I just added some days ago ^^'). Please report this one. That doesn't look right to my eyes but ok. I filed a report (https://bugs.freepascal.org/view.php?id=36377). The idea is that "specialize" belongs to the identifier just like "generic" does. This comes especially apparent for nested specializations: SomeUnit.specialize SomeType<... >.specialize SomeFunc<... > What's your plan to make an implicit specialize modeswitch? I remember you said you wanted to and it sounds like low-hanging fruit I could maybe help with. The specialize keyword is a bit much in my opinion and it sounds like it could be omitted like Delphi mode does. Well, if you want you can find any place where the _SPECIALIZE and _GENERIC tokens are used and checked against mode Delphi to check against a new modeswitch instead ("GENERICKEYWORDS") which must be enabled by default in all modes except the Delphi ones. Please note however that disabling the generic keywords also restricts some expressions that the compiler can handle as the Delphi syntax is not completly without ambiguity and not completly handled in the parser yet. Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Two possible generics bugs
Am 30.11.2019 um 18:56 schrieb Florian Klämpfl: Am 30.11.19 um 18:51 schrieb Sven Barth via fpc-pascal: Am 28.11.2019 um 16:14 schrieb Ryan Joseph via fpc-pascal: {$mode objfpc} program test; uses FGL; // Type identifier expected // Internal error 2019112401 generic function CopyList(source: specialize FGL.TFPGObjectList): specialize FGL.TFPGObjectList; begin end; begin end. What option did you use to compile it? What platform did you use? Cause I can't reproduce the internal error... r43612 | florian | 2019-11-29 23:13:17 +0100 (Fr, 29. Nov 2019) | 1 Zeile * better error recovery, resolves #36377 ;) That indeed explains it 😅 Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Two possible generics bugs
Am 29.11.2019 um 01:01 schrieb Ryan Joseph via fpc-pascal: function CopyList (source: TFPSList): TFPSList; begin result := TFPSList(source.ClassType.Create); result.Assign(source); end; This can't work. ClassType is of type TClass and TClass.Create calls TObject.Create, *not* the constructor of your list type, cause the constructor chain is not virtual. What you can do is this: === code begin === generic function CopyList (source: T): T; begin result := T.Create; result.Assign(source); end; var a, b: TNodeObjectList; begin a := TNodeObjectList.Create; b := specialize CopyList(a); end. === code end === Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Two possible generics bugs
Am 30.11.19 um 18:51 schrieb Sven Barth via fpc-pascal: Am 28.11.2019 um 16:14 schrieb Ryan Joseph via fpc-pascal: {$mode objfpc} program test; uses FGL; // Type identifier expected // Internal error 2019112401 generic function CopyList(source: specialize FGL.TFPGObjectList): specialize FGL.TFPGObjectList; begin end; begin end. What option did you use to compile it? What platform did you use? Cause I can't reproduce the internal error... r43612 | florian | 2019-11-29 23:13:17 +0100 (Fr, 29. Nov 2019) | 1 Zeile * better error recovery, resolves #36377 ;) ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Two possible generics bugs
Am 28.11.2019 um 16:14 schrieb Ryan Joseph via fpc-pascal: {$mode objfpc} program test; uses FGL; // Type identifier expected // Internal error 2019112401 generic function CopyList(source: specialize FGL.TFPGObjectList): specialize FGL.TFPGObjectList; begin end; begin end. What option did you use to compile it? What platform did you use? Cause I can't reproduce the internal error... === code begin === PS C:\fpc\git> .\compiler\ppcx64.exe -n -Furtl\units\x86_64-win64 -viwn -FEtestoutput .\tests\tbf\tb0272.pp Target OS: Win64 for x64 Compiling .\tests\tbf\tb0272.pp tb0272.pp(9,52) Error: Type identifier expected tb0272.pp(9,87) Error: Type identifier expected tb0272.pp(15) Fatal: There were 2 errors compiling module, stopping Fatal: Compilation aborted === code end === Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal