[Bug]: The put method does not handle hash-collided keys #41723
Labels
Area/Compiler
Lang/Table
Type `table` related issues
Reason/EngineeringMistake
The issue occurred due to a mistake made in the past.
Team/jBallerina
All the issues related to BIR, JVM backend code generation and runtime
Type/Bug
userCategory/Compilation
Milestone
Description
The current implementation of the
put
method in thetable
language library does not handle the case when there are two distinct keys with the same hash code. For instance, the output of the following code is[{"k":"10"},{"k":5},{"k":0},{"k":-31},{"k":100.05},{"k":30}]
when it should be[{"k":"10"},{"k":5},{"k":null},{"k":0},{"k":-31},{"k":100.05},{"k":30}]
.However, the
add
method of thetable
language library works as expected. For instance, the following code generates the expected result.Steps to Reproduce
Run the following Ballerina code.
Affected Version(s)
Ballerina 2201.8.1 (Swan Lake Update 8)
OS, DB, other environment details and versions
OS: macOS 14.0 23A344
Java: openjdk version "17.0.8" 2023-07-18
Related area
-> Compilation
Related issue(s) (optional)
No response
Suggested label(s) (optional)
No response
Suggested assignee(s) (optional)
No response
The text was updated successfully, but these errors were encountered: