mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-17 13:02:47 +00:00
fixes #25637 This pull request refactors the way the `sfInjectDestructors` flag is set on symbols during lambda lifting in the Nim compiler. The main change is the introduction of a helper procedure to encapsulate the logic for marking symbols that require destructor injection, improving code clarity and maintainability. Refactoring and code quality improvements: * Introduced the `markInjectDestructors` procedure to encapsulate the logic for marking a symbol with the `sfInjectDestructors` flag, ensuring that `backendEnsureMutable` is always called before modifying the symbol's flags. * Replaced direct flag manipulation (`owner.incl sfInjectDestructors` and `prc.incl sfInjectDestructors`) with calls to the new `markInjectDestructors` procedure in multiple locations, including `makeClosure`, `createTypeBoundOpsLL`, and `rawClosureCreation`. [[1]](diffhunk://#diff-19193904ba011a2bcc1e1a9768a7eb57cac57a274cad73d388149776ec2901e6L231-R235) [[2]](diffhunk://#diff-19193904ba011a2bcc1e1a9768a7eb57cac57a274cad73d388149776ec2901e6L243-R247) [[3]](diffhunk://#diff-19193904ba011a2bcc1e1a9768a7eb57cac57a274cad73d388149776ec2901e6L639-R643)