Skip to content

refactor(map): deprecate op-get for future migration #2017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

peter-jerry-ye
Copy link
Collaborator

@peter-jerry-ye peter-jerry-ye commented Apr 27, 2025

In the future, we will have op_get return V instead of V? and get return V?.

For other functions, if there are a 'unsafe' implementation and a 'safe', the unsafe one will be named as unsafe_xxx. Otherwise it will just named as it is.

cc @Yoorkin the json.mbt emitted two same warnings

@peter-jerry-ye peter-jerry-ye requested a review from bobzhang April 27, 2025 08:06
Copy link

Fixed potential undefined behavior in json.mbt by replacing array access with explicit get

Category
Correctness
Code Snippet
json.mbt:73

  • Some(obj) => obj[key]
  • Some(obj) => obj.get(key)
    Recommendation
    The change to use obj.get(key) is correct and should be kept
    Reasoning
    Using array access operator ([]) might have different semantics than get() in some implementations. Using get() is more explicit about returning an optional value and safer.
Deprecation notices should include migration instructions

Category
Maintainability
Code Snippet
linked_hash_map.mbt:199
#deprecated("Use get instead. op_get will return V instead of Option[V] in the future.")
Recommendation
Consider adding more context about timing of the breaking change and whether there are any other considerations for migration
Reasoning
Good deprecation messages help users understand not just what to change, but when they need to change it and what implications the change might have

Consistent deprecation messages across all implementations

Category
Maintainability
Code Snippet
Multiple files have #deprecated annotations, some with messages and some without
Recommendation
Add the same detailed deprecation message to all interface files (.mbti)
Reasoning
Having consistent deprecation messages across all implementations helps users understand the changes needed regardless of which map implementation they're using

@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 6466

Details

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.03%) to 92.695%

Totals Coverage Status
Change from base Build 6455: 0.03%
Covered Lines: 6116
Relevant Lines: 6598

💛 - Coveralls

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.

2 participants