Skip to content

Bug in push_to_map_of_vec template #98

@niketagl

Description

@niketagl

push_to_map_of_vec constructs a new fusion map from scratch using make_vector and make_pair, which only contains the single new key-value pair being added. (ref)

This approach:

  • Discards all existing entries in the original map.
  • Only preserves the current key-value pair being processed.
  • Fails to maintain the accumulated state information across multiple operations.

Here’s how I think this can be fixed:

  • Convert the map to a vector representation
  • Remove the existing entry for the key (if present)
  • Create a new entry with the updated vector (original vector + new element)
  • Add the new entry back to the vector
  • Convert back to map format

The fix would maintain the same interface while correcting the fundamental logic error in map manipulation.
I wanted to run it through you and get your feedback @henry-ch before raising a bugfix PR. Please let me know your thoughts on this!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions