File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
sway-core/src/decl_engine Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -240,6 +240,15 @@ impl SubstTypes for DeclId<TyTraitType> {
240240 }
241241}
242242
243+ // This implementation deviates from all other DeclId<...> implementations.
244+ // For more, see https://github.com/FuelLabs/sway/pull/7440#discussion_r2428833840.
245+ // A better solution will be implemented in the future.
246+ //
247+ // TL;DR:
248+ // When a constant is declared inside a function, its value is shared by every
249+ // “version” of that function—that is, by all monomorphizations. If we “replace” the
250+ // constant, as other implementations do, we would change its value in *every* version,
251+ // which is incorrect.
243252impl SubstTypes for DeclId < TyConstantDecl > {
244253 fn subst_inner ( & mut self , ctx : & SubstTypesContext ) -> HasChanges {
245254 let decl_engine = ctx. engines . de ( ) ;
You can’t perform that action at this time.
0 commit comments