File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -1190,9 +1190,14 @@ public final class LLVMCodeGenerator {
11901190
11911191 // Unbind all variables that will be bound in the loop body
11921192 // This simulates the child context behavior of the interpreter,
1193- // allowing variables to be rebound on each iteration
1193+ // allowing variables to be rebound on each iteration.
1194+ // Exclude the item variable and index variable — they are already
1195+ // managed by the dedicated unbind+rebind code above, mirroring
1196+ // the same exclusion in generateRangeLoop (line: varName != loop.variable).
1197+ var managedByLoop = Set ( [ loop. itemVariable] )
1198+ if let indexVar = loop. indexVariable { managedByLoop. insert ( indexVar) }
11941199 let bodyVariables = collectBoundVariables ( from: loop. body)
1195- for varName in bodyVariables {
1200+ for varName in bodyVariables where !managedByLoop . contains ( varName ) {
11961201 let varNameConst = ctx. stringConstant ( varName)
11971202 _ = ctx. module. insertCall (
11981203 externals. variableUnbind,
Original file line number Diff line number Diff line change @@ -1417,6 +1417,13 @@ private func convertToSendable(_ value: Any) -> any Sendable {
14171417 // This case should not be reached on macOS (CFBoolean is NSNumber)
14181418 // But keep it for other platforms
14191419 return bool
1420+ case let sendableDict as [ String : any Sendable ] :
1421+ // Already the correct type — recurse to ensure nested values are also clean
1422+ var result : [ String : any Sendable ] = [ : ]
1423+ for (k, v) in sendableDict {
1424+ result [ k] = convertToSendable ( v)
1425+ }
1426+ return result
14201427 case let dict as [ String : Any ] :
14211428 var result : [ String : any Sendable ] = [ : ]
14221429 for (k, v) in dict {
You can’t perform that action at this time.
0 commit comments