Opened at 2011-10-07T02:10:00Z
Last modified at 2012-03-29T23:27:02Z
#1555 closed enhancement
add check-miscaptures.py script to check for incorrect variable captures in for loops — at Version 1
Reported by: | davidsarah | Owned by: | somebody |
---|---|---|---|
Priority: | major | Milestone: | 1.9.2 |
Component: | code | Version: | 1.9.0a2 |
Keywords: | miscapture coding-tools review-needed | Cc: | |
Launchpad Bug: |
Description (last modified by davidsarah)
The attached script checks for errors in which a variable declared in a for loop is captured by a lambda or function definition. If the lambda/function is executed after the loop iteration in which it was created, it will refer to some later value of the variable, which is usually not what was intended.
The script currently produces false positives if a variable is declared and used in the same lambda/function within a for loop (i.e. it is not captured). I don't intend to fix that until after the Tahoe summit in November, probably. However, it produces relatively few false positives already, and found some genuine bugs (see #1556).
Change History (2)
comment:1 Changed at 2011-10-07T02:12:14Z by davidsarah
- Description modified (diff)
Add misc/coding_tools/check-miscaptures.py to detect incorrect captures of variables declared in a for loop, and a 'make check-miscaptures' Makefile target to run it. (It is also run by 'make code-checks'.) refs #1555