Merge pull request #3288 from enquora/CPSetTest-fix-test-warning

Fix static analysis warnings for unused iteration variables in Founda…
This commit is contained in:
David Richardson
2026-08-20 21:23:40 -06:00
committed by GitHub
2 changed files with 15 additions and 1 deletions
+6 -1
View File
@@ -490,8 +490,11 @@
var result = [CPMutableDictionary dictionary];
// Test basic for...of iteration
for (var [key, value] of dict)
for (var entry of dict)
{
var key = entry[0],
value = entry[1];
[result setObject:value forKey:key];
}
@@ -514,6 +517,8 @@
var iterations = 0;
for (var entry of emptyDict)
{
// Explicitly evaluate the bound variable to satisfy the static analyzer.
[entry self];
iterations++;
}
[self assert:0 equals:iterations message:@"for...of on an empty dictionary should not iterate"];
+9
View File
@@ -428,10 +428,19 @@
// 3. Test on an empty set
/*
The bound variable must be explicitly read to satisfy the static analyzer.
Standard JavaScript idioms for unused variables, such as the `_` identifier
or the `void` operator, either fail linting or trigger AST collisions in the
legacy Node.js parser. Evaluating the variable via a standard Objective-J
message send resolves the warning while preserving parser stability.
*/
var emptySet = [CPSet set];
var iterations = 0;
for (var entry of emptySet)
{
[itemsSeen addObject:entry];
iterations++;
}
[self assert:0 equals:iterations message:@"for...of on an empty set should not iterate"];