From 84dab559931965080ef60e99ce8cd483bb2d8cea Mon Sep 17 00:00:00 2001 From: David Richardson Date: Tue, 11 Aug 2026 13:04:05 -0600 Subject: [PATCH] Fix legacy compiler warnings in CPMapTable Using ES6 destructuring in the `for...of` loop declaration (`var [key, value] of _map.entries()`) causes the legacy Objective-J compiler to emit "uninitialized global variable" warnings for `key` and `value`. This raises concerns about variable scoping and generates unacceptable noise in the CI pipeline. To resolve the warnings, the loop has been restructured to use standard array indexing inside the loop body. A TODO has been added to revert to ES6 destructuring once the legacy compiler is retired. --- Foundation/CPMapTable.j | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/Foundation/CPMapTable.j b/Foundation/CPMapTable.j index 58ebbd861..bc853e78c 100644 --- a/Foundation/CPMapTable.j +++ b/Foundation/CPMapTable.j @@ -105,17 +105,31 @@ // MARK: Creating a Dictionary Representation /*! - Returns a dictionary representation of the map table. - Note: This will only work correctly if all keys are strings. + Returns a dictionary representation of the map table. + Note: This will only work correctly if all keys are strings. - @return A CPDictionary containing the entries of the map table. + @return A CPDictionary containing the entries of the map table. */ - (CPDictionary)dictionaryRepresentation { var dictionary = [CPDictionary dictionary]; - for (var [key, value] of _map.entries()) + // TODO: Revert to ES6 destructuring in the loop declaration once the + // legacy compiler is retired. The legacy parser fails to recognize + // `var [key, value]` as a local scope declaration, causing the variables + // to leak to the global object and emitting false-positive "uninitialized + // global variable" warnings, which is unacceptable for CI hygiene. + // + // for (var [key, value] of _map.entries()) + // { + // [dictionary setObject:value forKey:key]; + // } + + for (var entry of _map.entries()) { + var key = entry[0], + value = entry[1]; + [dictionary setObject:value forKey:key]; }