Forum > Packages and Libraries
Generics.Collections TDictionary issue
Thaddy:
Same here with trunk, both linux debian bookworm and windows 10/11. Works OK.
JdeHaan:
Thanks all for testing.
If someone could also test it on MacOS Ventura (13.2), that would be appreciated...
Because it didn't happen before ( I just updated this week to Ventura 13.2 and also installed latest trunk of FPC).
avk:
IMHO, Generics.Collections looks broken at the moment. At least this simple test:
--- 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 test; {$mode objfpc}{$h+} uses SysUtils, Generics.Collections, Generics.Defaults, Generics.Hashes; type TByte8 = array[0..7] of byte; TByteMap = specialize TDictionary<TByte8, Integer>; function EqualB8(const L, R: TByte8): Boolean;begin Result := CompareByte(L, R, SizeOf(TByte8)) = 0;end; function B8Hash(const aValue: TByte8): UInt32;begin Result := xxHash32(0, @aValue, SizeOf(TByte8));end; var b8: TByte8 = (1,2,3,4,5,6,7,8); Map: TByteMap;begin Map := TByteMap.Create; if Map.TryAdd(b8, 42) then WriteLn('Ok, added'); if Map.ContainsKey(b8) then WriteLn('Ok, contains') else WriteLn('No such key'); Map.Free; ///////////////// WriteLn; Map := TByteMap.Create(specialize TEqualityComparer<TByte8>.Construct(@EqualB8, @B8Hash)); if Map.TryAdd(b8, 42) then WriteLn('Ok, added'); if Map.ContainsKey(b8) then WriteLn('Ok, contains') else WriteLn('No such key'); Map.Free;end.
produces the following result:
--- Code: Text [+][-]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";}};} ---Ok, addedNo such key Ok, addedOk, contains
dseligo:
--- Quote from: avk on January 29, 2023, 03:13:06 pm ---IMHO, Generics.Collections looks broken at the moment. At least this simple test:
--- End quote ---
This doesn't compile in Lazarus 2.2.4 (rev lazarus_2_2_4) FPC 3.2.2 x86_64-win64-win32/win64.
--- Code: Text [+][-]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";}};} ---test2.lpr(36,90) Error: Incompatible type for arg no. 2: Got "<address of function(const TByte8):DWord;Register>", expected "<procedure variable type of function(constref TByte8):DWord;Register>"
TRon:
@deseligo:
compiles with trunk but with result as shown by avk.
Navigation
[0] Message Index
[#] Next page
[*] Previous page