Skip to content

[lint] Suggest direct iteration over dictionary keys#618

Merged
turbolent merged 1 commit intomasterfrom
bastian/dictionary-keys-iteration-analyzer
Apr 7, 2026
Merged

[lint] Suggest direct iteration over dictionary keys#618
turbolent merged 1 commit intomasterfrom
bastian/dictionary-keys-iteration-analyzer

Conversation

@turbolent
Copy link
Copy Markdown
Member

Description

Since Cadence v1.10.0 direct iteration over dictionaries is supported, which avoids temporarily constructing an array of all keys.

Add a new analyzer which detects for key in dict.keys { ... } and suggests replacing it with just for key in dict { ... }.


  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

@turbolent turbolent self-assigned this Apr 7, 2026
Copy link
Copy Markdown
Member

@SupunS SupunS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@turbolent turbolent merged commit a3c7d03 into master Apr 7, 2026
10 checks passed
@turbolent turbolent deleted the bastian/dictionary-keys-iteration-analyzer branch April 7, 2026 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants