Skip to content

Fix mutable generic at lookup - #3006

Open
sean0407 wants to merge 1 commit into
stephenberry:mainfrom
sean0407:codex/glaze-mutable-at
Open

sean0407 wants to merge 1 commit into
stephenberry:mainfrom
sean0407:codex/glaze-mutable-at

Conversation

@sean0407

Copy link
Copy Markdown

Summary

glz::generic::at(key) currently delegates to mutable operator[], which inserts a missing object key. Route mutable at() through the existing checked const lookup, then return the existing value as a mutable reference.

Fixes #3000.

mutable at(key)
  before: operator[](key)   // inserts when absent
  after:  checked lookup    // errors when absent; never inserts

Evidence

  • Before: An isolated C++23 reproducer confirmed that json.at("missing") inserted the key.
  • After: The same isolated check confirmed that existing-key lookup still works, while missing-key lookup throws and leaves the object unchanged.
  • Added a regression case for both existing and missing keys.

Merge Danger

Door: two-way

Blast Radius: low

@packit-as-a-service

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

at() on a mutable glz::generic inserts missing keys

1 participant