TStringList.AddObject works incorrectly in the Duplicates = dupIgnore mode
Summary
The object passed to TStringList.AddObject replaces the original object of the item regardless of Duplicates = dupIgnore mode.
System Information
- Operating system: Alt Linux 10.2
- Processor architecture: x86-64
- Compiler version: trunk
- Device: Computer
Steps to reproduce
List.Sorted := True;
List.Duplicates := dupIgnore;
List.AddObject('item1', Object1);
List.AddObject('item1', Object2);
Assert(List.Objects[List.IndexOf('item1')] = Object1);
What is the current bug behavior?
The Object2 replaces the original object of the item.
What is the expected (correct) behavior?
The item keeps the Object1.
Possible fixes
Suggested patch: fpc_stringlist_patch.patch