Use DeclEngine::insert_modified instead of replace - #7717
Conversation
PR SummaryMedium Risk Overview
The long comment on Reviewed by Cursor Bugbot for commit 01d1aff. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
👍 |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 01d1aff. Configure here.

Description
This PR is a prerequisite for removals of duplicates from
DeclEngineand for elimination of expensive hashing.The PR removes most of the usages of
DeclEngine::replace, up to those used intype_check_impl_selfand intype_check_method_application(the usage inimpl ReplaceFunctionImplementingType for DeclRefFunctionwe consider to be a part oftype_check_impl_self). Those remaining usages will be removed in a separate follow up PR.Beside being a show-stopper for
DeclEngineimprovements,DeclEngine::replaceusage in the cases tackled in this PR was error-prone. Its callers assumed that the replacedTyDeclwas not reused by different declarations. As the all passing tests confirm, this assumption currently holds. But note that we already had issues in the past withTyConstantDeclwhere replacing shared declarations was causing side-effects and causing bugs in the compilation.impl SubstTypes for DeclId<TyConstantDecl>was already usinginsert_modifiedinstead ofreplacewith a comment explaining why. This PR merely roles out that correct pattern to allTyDecls.Checklist
Breaking*orNew Featurelabels where relevant.