Forum > General
Private property of a Generic Type
Okoba:
I have codes like this that worked just find until recent versions, but current Trunk says "unit1.pas(22,5) Error: Identifier idents no member "A""
Why? And what can I do to fix it? I do not want to expose these fields.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program Project1; {$mode Delphi} uses unit1; var V: TTest<Integer>;begin Inc<Integer>(V); ReadLn;end.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---unit Unit1; {$mode Delphi} interface type TTest<T> = record private A: T; end; procedure Inc<T>(var v: TTest<T>); implementation procedure Inc<T>(var v: TTest<T>);begin V.A += 1; //Error!end; end.
ASerge:
--- Quote from: Okoba on February 26, 2024, 05:39:51 pm ---...until recent versions...
--- End quote ---
Which?
TRon:
I assume Okoba meant 3.2.2 ASerge.
--- Code: ---fpc -B project1.pas
Free Pascal Compiler version 3.2.2 [2021/05/16] for x86_64
Copyright (c) 1993-2021 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling project1.pas
Compiling unit1.pas
unit1.pas(10,9) Note: Private field "<record type>.A" is never used
Linking project1
35 lines compiled, 0.0 sec
1 note(s) issued
--- End code ---
Note the irony :)
My most recent trunk is apparently too old as 3.3.1 compiles the project for me as well.
Compilation with brand new trunk:
--- Code: ---$ fpc-trunk -B project1.pas
Free Pascal Compiler version 3.3.1 [2024/02/26] for x86_64
Copyright (c) 1993-2024 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling project1.pas
Compiling unit1.pas
unit1.pas(10,9) Note: Private field "<record type>.A" is never used
unit1.pas(19,9) Error: Identifier idents no member "A"
project1.pas(14) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: /media/ramdisk/fpc/3.3.1/bin/ppcx64 returned an error exitcode
--- End code ---
Okoba:
@ASerge I dont know. What I know is until 2024-02-02 it is working but when I get the latest trunk I get this error.
zamtmn:
Yes, they closed the loophole. It's just not clear why you should try to hide everything, it's often not justified((
I used write access to container data, now it's not allowed and I need to add it to the rtl code
https://gitlab.com/freepascal.org/fpc/source/-/issues/40656
https://gitlab.com/freepascal.org/fpc/source/-/merge_requests/593
Navigation
[0] Message Index
[#] Next page