@@ -285,7 +285,9 @@ public struct EscapeEffects : CustomStringConvertible, NoReflectionChildren {
285
285
/// Note that theoretically this rule also applies to the `escapingToReturn` effect, but it's impossible
286
286
/// to construct such a situation for an argument which is only escaping to the function return.
287
287
///
288
- case escapingToArgument(toArgumentIndex: Int, toPath: SmallProjectionPath, isExclusive: Bool)
288
+ /// The `escapingToArgument` doesn't have an `isExclusive` flag, because an argument-to-argument escape
289
+ /// always involves a store, which makes an exclusive escape impossible.
290
+ case escapingToArgument(toArgumentIndex: Int, toPath: SmallProjectionPath)
289
291
}
290
292
291
293
/// To which argument does this effect apply to?
@@ -330,19 +332,19 @@ public struct EscapeEffects : CustomStringConvertible, NoReflectionChildren {
330
332
if resultArgDelta != 1 {
331
333
return nil
332
334
}
333
- self.kind = .escapingToArgument(toArgumentIndex: 0, toPath: toPath, isExclusive: exclusive )
335
+ self.kind = .escapingToArgument(toArgumentIndex: 0, toPath: toPath)
334
336
} else {
335
337
self.kind = .escapingToReturn(toPath: toPath, isExclusive: exclusive)
336
338
}
337
- case .escapingToArgument(let toArgIdx, let toPath, let exclusive ):
339
+ case .escapingToArgument(let toArgIdx, let toPath):
338
340
let resultingToArgIdx = toArgIdx + resultArgDelta
339
341
if resultingToArgIdx < 0 {
340
342
if resultingToArgIdx != -1 {
341
343
return nil
342
344
}
343
- self.kind = .escapingToReturn(toPath: toPath, isExclusive: exclusive )
345
+ self.kind = .escapingToReturn(toPath: toPath, isExclusive: false )
344
346
} else {
345
- self.kind = .escapingToArgument(toArgumentIndex: resultingToArgIdx, toPath: toPath, isExclusive: exclusive )
347
+ self.kind = .escapingToArgument(toArgumentIndex: resultingToArgIdx, toPath: toPath)
346
348
}
347
349
}
348
350
}
@@ -362,9 +364,9 @@ public struct EscapeEffects : CustomStringConvertible, NoReflectionChildren {
362
364
case .escapingToReturn(let toPath, let exclusive):
363
365
let toPathStr = (toPath.isEmpty ? "" : ".\(toPath)")
364
366
return "escape\(patternStr) \(exclusive ? "=>" : "->") %r\(toPathStr)"
365
- case .escapingToArgument(let toArgIdx, let toPath, let exclusive ):
367
+ case .escapingToArgument(let toArgIdx, let toPath):
366
368
let toPathStr = (toPath.isEmpty ? "" : ".\(toPath)")
367
- return "escape\(patternStr) \(exclusive ? "=>" : "->") %\(toArgIdx)\(toPathStr)"
369
+ return "escape\(patternStr) -> %\(toArgIdx)\(toPathStr)"
368
370
}
369
371
}
370
372
@@ -663,16 +665,21 @@ extension StringParser {
663
665
try throwError("multi-value returns not supported yet")
664
666
}
665
667
let toPath = try parsePathPatternFromSource(for: function, type: function.argumentTypes[0])
666
- return EscapeEffects.ArgumentEffect(.escapingToArgument(toArgumentIndex: 0, toPath: toPath, isExclusive: exclusive),
668
+
669
+ // Exclusive escapes are ignored for indirect return values.
670
+ return EscapeEffects.ArgumentEffect(.escapingToArgument(toArgumentIndex: 0, toPath: toPath),
667
671
argumentIndex: fromArgIdx, pathPattern: fromPath, isDerived: false)
668
672
}
669
673
let toPath = try parsePathPatternFromSource(for: function, type: function.resultType)
670
674
return EscapeEffects.ArgumentEffect(.escapingToReturn(toPath: toPath, isExclusive: exclusive),
671
675
argumentIndex: fromArgIdx, pathPattern: fromPath, isDerived: false)
672
676
}
677
+ if exclusive {
678
+ try throwError("exclusive escapes to arguments are not supported")
679
+ }
673
680
let toArgIdx = try parseArgumentIndexFromSource(for: function, params: params)
674
681
let toPath = try parsePathPatternFromSource(for: function, type: function.argumentTypes[toArgIdx])
675
- return EscapeEffects.ArgumentEffect(.escapingToArgument(toArgumentIndex: toArgIdx, toPath: toPath, isExclusive: exclusive ),
682
+ return EscapeEffects.ArgumentEffect(.escapingToArgument(toArgumentIndex: toArgIdx, toPath: toPath),
676
683
argumentIndex: fromArgIdx, pathPattern: fromPath, isDerived: false)
677
684
}
678
685
try throwError("unknown effect")
@@ -739,9 +746,12 @@ extension StringParser {
739
746
effect = EscapeEffects.ArgumentEffect(.escapingToReturn(toPath: toPath, isExclusive: exclusive),
740
747
argumentIndex: argumentIndex, pathPattern: fromPath, isDerived: isDerived)
741
748
} else {
749
+ if exclusive {
750
+ try throwError("exclusive escapes to arguments are not supported")
751
+ }
742
752
let toArgIdx = try parseArgumentIndexFromSIL()
743
753
let toPath = consume(".") ? try parseProjectionPathFromSIL() : SmallProjectionPath()
744
- effect = EscapeEffects.ArgumentEffect(.escapingToArgument(toArgumentIndex: toArgIdx, toPath: toPath, isExclusive: exclusive ),
754
+ effect = EscapeEffects.ArgumentEffect(.escapingToArgument(toArgumentIndex: toArgIdx, toPath: toPath),
745
755
argumentIndex: argumentIndex, pathPattern: fromPath, isDerived: isDerived)
746
756
}
747
757
effects.escapeEffects.arguments.append(effect)
0 commit comments