diff --git a/shared/typeinference/codeql/typeinference/internal/TypeInference.qll b/shared/typeinference/codeql/typeinference/internal/TypeInference.qll index d75fc012ae90..1bcdf150ef03 100644 --- a/shared/typeinference/codeql/typeinference/internal/TypeInference.qll +++ b/shared/typeinference/codeql/typeinference/internal/TypeInference.qll @@ -2697,10 +2697,21 @@ module Make1 Input1> { module Make3 { private import Input3 + /** + * Gets a parameter's declaration pattern or an access to its implicit + * variable. + */ + private AstNode getAParameterInferenceNode(Parameter p) { + result = p.getPattern() + or + // Implicit parameters do not have a pattern, use an access instead. + result = any(Variable v | implicitParameterDecl(p, v)).getAnAccess() + } + pragma[nomagic] private predicate closureStep(AstNode pattern, TypePath prefix1, Expr c, TypePath prefix2) { exists(Closure c0, Parameter p | - pattern = p.getPattern() and + pattern = getAParameterInferenceNode(p) and p = c0.getParameter(_) and prefix1.isEmpty() and prefix2 = getClosureParameterTypePath(p) and @@ -3565,7 +3576,7 @@ module Make1 Input1> { hasClosureParameterPseudoType(n, prefix, p) and hasTypeAtPrefix(n, prefix, path) and path = prefix.appendInverse(suffix) and - pattern = p.getPattern() + pattern = getAParameterInferenceNode(p) ) } @@ -3580,7 +3591,7 @@ module Make1 Input1> { // QL doc for `ClosureParameterPseudoType`. exists(Closure c, Parameter p | p = c.getParameter(_) | // step 1 - n = p.getPattern() and + n = getAParameterInferenceNode(p) and path.isEmpty() and result.(ClosureParameterPseudoType).getParameter() = p or @@ -3614,7 +3625,7 @@ module Make1 Input1> { result instanceof UnknownType or // step 3 - n = p.getPattern() and + n = getAParameterInferenceNode(p) and result = inferType(def, getClosureParameterTypePath(p).appendInverse(path)) and not (path.isEmpty() and result instanceof UnknownType) ) diff --git a/unified/ql/lib/codeql/unified/internal/AstPlugin.qll b/unified/ql/lib/codeql/unified/internal/AstPlugin.qll index 02f02f92628a..fa472636c8a6 100644 --- a/unified/ql/lib/codeql/unified/internal/AstPlugin.qll +++ b/unified/ql/lib/codeql/unified/internal/AstPlugin.qll @@ -21,6 +21,17 @@ class AstPlugin extends Unit { bindingset[decl] string getVariableDeclarationKeyword(VariableDeclaration decl) { none() } + /** + * Holds if `ident` accesses an implicit function-expression parameter at + * index `n`. + * + * For instance: + * - In Kotlin `it` accesses an implicit parameter at index 0. + * - In Swift `$1` accesses an implicit parameter at index 1. + * - In Ruby `_2` accesses an implicit parameter at index 2. + */ + predicate implicitFunctionExprParamAccess(Identifier ident, int n) { none() } + /** * Holds if the default constructor `cd` needs a parameter at index `i` with * the given name. `hasDefault` indicates whether the parameter has a default @@ -65,6 +76,25 @@ string getVariableDeclarationKeyword(VariableDeclaration decl) { result = any(AstPlugin p).getVariableDeclarationKeyword(decl) } +/** + * Gets the name of the `n`th implicit parameter of function expression `fe`. + */ +string getImplicitFunctionExprParamName(FunctionExpr fe, int n) { + // For now we assume that an implicit parameter access always belongs to its + // enclosing function expression. This is correct for Swift but not in the + // following Kotlin example: + // ```kotlin + // listOf(1, 2).map { listOf(3, 4).map { inner -> it + inner } } + // ``` + // Here `it` refers to the outer function expression. The inner function + // expression has an explicit parameter list so it does not introduce `it`. + exists(Identifier ident | + any(AstPlugin p).implicitFunctionExprParamAccess(ident, n) and + fe = ident.getEnclosingCallable() and + result = ident.getValue() + ) +} + bindingset[cd] predicate defaultConstructorParameter( ConstructorDeclaration cd, int i, string name, boolean hasDefault diff --git a/unified/ql/lib/codeql/unified/internal/AstPluginSwift.qll b/unified/ql/lib/codeql/unified/internal/AstPluginSwift.qll index 858cdefc42e6..382d9d0cdbc3 100644 --- a/unified/ql/lib/codeql/unified/internal/AstPluginSwift.qll +++ b/unified/ql/lib/codeql/unified/internal/AstPluginSwift.qll @@ -58,6 +58,13 @@ private class AstPluginSwift extends AstPlugin { result in ["var", "let"] } + override predicate implicitFunctionExprParamAccess(Identifier ident, int n) { + // In Swift implicit function expression parameters are called "shorthand + // argument names" and are denoted by `$` followed by a number: + // https://docs.swift.org/latest/documentation/the-swift-programming-language/closures/#Shorthand-Argument-Names + n = ident.getValue().regexpCapture("\\$([0-9]+)", 1).toInt() + } + bindingset[cd] override predicate defaultConstructorParameter( ConstructorDeclaration cd, int i, string name, boolean hasDefault diff --git a/unified/ql/lib/codeql/unified/internal/FacadeAst.qll b/unified/ql/lib/codeql/unified/internal/FacadeAst.qll index cf97e6998bbb..294a2c02e835 100644 --- a/unified/ql/lib/codeql/unified/internal/FacadeAst.qll +++ b/unified/ql/lib/codeql/unified/internal/FacadeAst.qll @@ -436,8 +436,18 @@ module Unified { /** A function expression. */ class FunctionExpr extends G::FunctionExpr { - /** Gets the number of parameters of this function. */ - int getNumberOfParameters() { result = count(this.getAParameter()) } + /** Gets the number of implicit parameters, if any. */ + int getNumberOfImplicitParameters() { + result = max(int n | exists(getImplicitFunctionExprParamName(this, n)) | n) + 1 + } + + /** Gets the number of explicit or implicit parameters of this function. */ + int getNumberOfParameters() { + result = this.getNumberOfImplicitParameters() + or + not exists(this.getNumberOfImplicitParameters()) and + result = count(this.getAParameter()) + } } class ArrayLiteral extends G::ArrayLiteral { diff --git a/unified/ql/lib/codeql/unified/internal/LocalNameBinding.qll b/unified/ql/lib/codeql/unified/internal/LocalNameBinding.qll index 93ab37a81a9f..32dbc7b36842 100644 --- a/unified/ql/lib/codeql/unified/internal/LocalNameBinding.qll +++ b/unified/ql/lib/codeql/unified/internal/LocalNameBinding.qll @@ -7,6 +7,7 @@ module; private import unified private import unified as U private import codeql.namebinding.LocalNameBinding +private import codeql.unified.internal.AstPlugin private import codeql.unified.internal.NameBindingPlugin private import codeql.unified.internal.StaticNameBinding @@ -325,6 +326,9 @@ private module LocalNameBindingInput implements LocalNameBindingInputSig Void = { + let value = $0 + let inner: (String, String) -> Void = { + sink($0) // $ hasValueFlow=t15.2 + sink($1) // $ hasValueFlow=t15.3 + sink(value) // $ hasValueFlow=t15.1 + } + inner(source("t15.2"), source("t15.3")) + sink($0) // $ hasValueFlow=t15.1 + } + outer(source("t15.1")) +} + +func t16() { + let second: (String, String) -> String = { + sink($1) // $ hasValueFlow=t16.2 + } + second(source("t16.1"), source("t16.2")) +} + class C { var x: String diff --git a/unified/ql/test/library-tests/dataflow/test.expected b/unified/ql/test/library-tests/dataflow/test.expected index dbb1805a3c09..68e0e869fda8 100644 --- a/unified/ql/test/library-tests/dataflow/test.expected +++ b/unified/ql/test/library-tests/dataflow/test.expected @@ -180,30 +180,39 @@ edges | capture.swift:117:36:117:36 | x | capture.swift:117:29:117:32 | blah | provenance | | | capture.swift:147:5:147:5 | x | capture.swift:143:14:143:14 | x | provenance | | | capture.swift:147:9:147:23 | source(...) | capture.swift:147:5:147:5 | x | provenance | | -| capture.swift:156:9:156:9 | x | capture.swift:158:18:158:21 | self [x] | provenance | | -| capture.swift:156:13:156:25 | source(...) | capture.swift:156:9:156:9 | x | provenance | | -| capture.swift:158:18:158:21 | self [x] | capture.swift:158:18:158:23 | ... .x | provenance | | -| capture.swift:164:9:164:9 | x | capture.swift:165:26:165:29 | self [x] | provenance | | -| capture.swift:164:13:164:25 | source(...) | capture.swift:164:9:164:9 | x | provenance | | -| capture.swift:165:26:165:29 | self [x] | capture.swift:165:26:165:29 | self [x] | provenance | | -| capture.swift:165:26:165:29 | self [x] | capture.swift:166:18:166:21 | self [x] | provenance | | -| capture.swift:165:26:165:29 | self [x] | capture.swift:167:18:167:18 | x | provenance | | -| capture.swift:166:18:166:21 | self [x] | capture.swift:166:18:166:23 | ... .x | provenance | | -| capture.swift:173:9:173:9 | x | capture.swift:174:31:174:34 | self [x] | provenance | | -| capture.swift:173:13:173:25 | source(...) | capture.swift:173:9:173:9 | x | provenance | | -| capture.swift:174:31:174:34 | self [x] | capture.swift:174:31:174:34 | self [x] | provenance | | -| capture.swift:174:31:174:34 | self [x] | capture.swift:175:23:175:26 | self [x] | provenance | | -| capture.swift:175:19:175:26 | ... .some(...) [x] | capture.swift:175:23:175:26 | self [x] | provenance | | -| capture.swift:175:23:175:26 | self [x] | capture.swift:175:19:175:26 | ... .some(...) [x] | provenance | | -| capture.swift:175:23:175:26 | self [x] | capture.swift:176:18:176:21 | self [x] | provenance | | -| capture.swift:175:23:175:26 | self [x] | capture.swift:177:18:177:18 | x | provenance | | -| capture.swift:176:18:176:21 | self [x] | capture.swift:176:18:176:23 | ... .x | provenance | | -| capture.swift:183:9:183:9 | x | capture.swift:184:34:184:37 | self [x] | provenance | | -| capture.swift:183:13:183:25 | source(...) | capture.swift:183:9:183:9 | x | provenance | | -| capture.swift:184:34:184:37 | self [x] | capture.swift:184:34:184:37 | self [x] | provenance | | -| capture.swift:184:34:184:37 | self [x] | capture.swift:185:18:185:21 | self [x] | provenance | | -| capture.swift:184:34:184:37 | self [x] | capture.swift:186:18:186:18 | x | provenance | | -| capture.swift:185:18:185:21 | self [x] | capture.swift:185:18:185:23 | ... .x | provenance | | +| capture.swift:158:13:158:27 | source(...) | capture.swift:154:14:154:15 | $0 | provenance | | +| capture.swift:158:30:158:44 | source(...) | capture.swift:155:14:155:15 | $1 | provenance | | +| capture.swift:163:13:163:17 | value | capture.swift:167:18:167:22 | value | provenance | | +| capture.swift:163:21:163:22 | $0 | capture.swift:163:13:163:17 | value | provenance | | +| capture.swift:169:15:169:29 | source(...) | capture.swift:165:18:165:19 | $0 | provenance | | +| capture.swift:169:32:169:46 | source(...) | capture.swift:166:18:166:19 | $1 | provenance | | +| capture.swift:172:11:172:25 | source(...) | capture.swift:163:21:163:22 | $0 | provenance | | +| capture.swift:172:11:172:25 | source(...) | capture.swift:170:14:170:15 | $0 | provenance | | +| capture.swift:179:29:179:43 | source(...) | capture.swift:177:14:177:15 | $1 | provenance | | +| capture.swift:186:9:186:9 | x | capture.swift:188:18:188:21 | self [x] | provenance | | +| capture.swift:186:13:186:25 | source(...) | capture.swift:186:9:186:9 | x | provenance | | +| capture.swift:188:18:188:21 | self [x] | capture.swift:188:18:188:23 | ... .x | provenance | | +| capture.swift:194:9:194:9 | x | capture.swift:195:26:195:29 | self [x] | provenance | | +| capture.swift:194:13:194:25 | source(...) | capture.swift:194:9:194:9 | x | provenance | | +| capture.swift:195:26:195:29 | self [x] | capture.swift:195:26:195:29 | self [x] | provenance | | +| capture.swift:195:26:195:29 | self [x] | capture.swift:196:18:196:21 | self [x] | provenance | | +| capture.swift:195:26:195:29 | self [x] | capture.swift:197:18:197:18 | x | provenance | | +| capture.swift:196:18:196:21 | self [x] | capture.swift:196:18:196:23 | ... .x | provenance | | +| capture.swift:203:9:203:9 | x | capture.swift:204:31:204:34 | self [x] | provenance | | +| capture.swift:203:13:203:25 | source(...) | capture.swift:203:9:203:9 | x | provenance | | +| capture.swift:204:31:204:34 | self [x] | capture.swift:204:31:204:34 | self [x] | provenance | | +| capture.swift:204:31:204:34 | self [x] | capture.swift:205:23:205:26 | self [x] | provenance | | +| capture.swift:205:19:205:26 | ... .some(...) [x] | capture.swift:205:23:205:26 | self [x] | provenance | | +| capture.swift:205:23:205:26 | self [x] | capture.swift:205:19:205:26 | ... .some(...) [x] | provenance | | +| capture.swift:205:23:205:26 | self [x] | capture.swift:206:18:206:21 | self [x] | provenance | | +| capture.swift:205:23:205:26 | self [x] | capture.swift:207:18:207:18 | x | provenance | | +| capture.swift:206:18:206:21 | self [x] | capture.swift:206:18:206:23 | ... .x | provenance | | +| capture.swift:213:9:213:9 | x | capture.swift:214:34:214:37 | self [x] | provenance | | +| capture.swift:213:13:213:25 | source(...) | capture.swift:213:9:213:9 | x | provenance | | +| capture.swift:214:34:214:37 | self [x] | capture.swift:214:34:214:37 | self [x] | provenance | | +| capture.swift:214:34:214:37 | self [x] | capture.swift:215:18:215:21 | self [x] | provenance | | +| capture.swift:214:34:214:37 | self [x] | capture.swift:216:18:216:18 | x | provenance | | +| capture.swift:215:18:215:21 | self [x] | capture.swift:215:18:215:23 | ... .x | provenance | | | enums.swift:12:9:12:9 | e [case1.0] | enums.swift:14:12:14:12 | e [case1.0] | provenance | | | enums.swift:12:13:12:35 | ... .case1(...) [case1.0] | enums.swift:12:9:12:9 | e [case1.0] | provenance | | | enums.swift:12:21:12:34 | source(...) | enums.swift:12:13:12:35 | ... .case1(...) [case1.0] | provenance | | @@ -838,34 +847,49 @@ nodes | capture.swift:143:14:143:14 | x | semmle.label | x | | capture.swift:147:5:147:5 | x | semmle.label | x | | capture.swift:147:9:147:23 | source(...) | semmle.label | source(...) | -| capture.swift:156:9:156:9 | x | semmle.label | x | -| capture.swift:156:13:156:25 | source(...) | semmle.label | source(...) | -| capture.swift:158:18:158:21 | self [x] | semmle.label | self [x] | -| capture.swift:158:18:158:23 | ... .x | semmle.label | ... .x | -| capture.swift:164:9:164:9 | x | semmle.label | x | -| capture.swift:164:13:164:25 | source(...) | semmle.label | source(...) | -| capture.swift:165:26:165:29 | self [x] | semmle.label | self [x] | -| capture.swift:165:26:165:29 | self [x] | semmle.label | self [x] | -| capture.swift:166:18:166:21 | self [x] | semmle.label | self [x] | -| capture.swift:166:18:166:23 | ... .x | semmle.label | ... .x | -| capture.swift:167:18:167:18 | x | semmle.label | x | -| capture.swift:173:9:173:9 | x | semmle.label | x | -| capture.swift:173:13:173:25 | source(...) | semmle.label | source(...) | -| capture.swift:174:31:174:34 | self [x] | semmle.label | self [x] | -| capture.swift:174:31:174:34 | self [x] | semmle.label | self [x] | -| capture.swift:175:19:175:26 | ... .some(...) [x] | semmle.label | ... .some(...) [x] | -| capture.swift:175:23:175:26 | self [x] | semmle.label | self [x] | -| capture.swift:175:23:175:26 | self [x] | semmle.label | self [x] | -| capture.swift:176:18:176:21 | self [x] | semmle.label | self [x] | -| capture.swift:176:18:176:23 | ... .x | semmle.label | ... .x | -| capture.swift:177:18:177:18 | x | semmle.label | x | -| capture.swift:183:9:183:9 | x | semmle.label | x | -| capture.swift:183:13:183:25 | source(...) | semmle.label | source(...) | -| capture.swift:184:34:184:37 | self [x] | semmle.label | self [x] | -| capture.swift:184:34:184:37 | self [x] | semmle.label | self [x] | -| capture.swift:185:18:185:21 | self [x] | semmle.label | self [x] | -| capture.swift:185:18:185:23 | ... .x | semmle.label | ... .x | -| capture.swift:186:18:186:18 | x | semmle.label | x | +| capture.swift:154:14:154:15 | $0 | semmle.label | $0 | +| capture.swift:155:14:155:15 | $1 | semmle.label | $1 | +| capture.swift:158:13:158:27 | source(...) | semmle.label | source(...) | +| capture.swift:158:30:158:44 | source(...) | semmle.label | source(...) | +| capture.swift:163:13:163:17 | value | semmle.label | value | +| capture.swift:163:21:163:22 | $0 | semmle.label | $0 | +| capture.swift:165:18:165:19 | $0 | semmle.label | $0 | +| capture.swift:166:18:166:19 | $1 | semmle.label | $1 | +| capture.swift:167:18:167:22 | value | semmle.label | value | +| capture.swift:169:15:169:29 | source(...) | semmle.label | source(...) | +| capture.swift:169:32:169:46 | source(...) | semmle.label | source(...) | +| capture.swift:170:14:170:15 | $0 | semmle.label | $0 | +| capture.swift:172:11:172:25 | source(...) | semmle.label | source(...) | +| capture.swift:177:14:177:15 | $1 | semmle.label | $1 | +| capture.swift:179:29:179:43 | source(...) | semmle.label | source(...) | +| capture.swift:186:9:186:9 | x | semmle.label | x | +| capture.swift:186:13:186:25 | source(...) | semmle.label | source(...) | +| capture.swift:188:18:188:21 | self [x] | semmle.label | self [x] | +| capture.swift:188:18:188:23 | ... .x | semmle.label | ... .x | +| capture.swift:194:9:194:9 | x | semmle.label | x | +| capture.swift:194:13:194:25 | source(...) | semmle.label | source(...) | +| capture.swift:195:26:195:29 | self [x] | semmle.label | self [x] | +| capture.swift:195:26:195:29 | self [x] | semmle.label | self [x] | +| capture.swift:196:18:196:21 | self [x] | semmle.label | self [x] | +| capture.swift:196:18:196:23 | ... .x | semmle.label | ... .x | +| capture.swift:197:18:197:18 | x | semmle.label | x | +| capture.swift:203:9:203:9 | x | semmle.label | x | +| capture.swift:203:13:203:25 | source(...) | semmle.label | source(...) | +| capture.swift:204:31:204:34 | self [x] | semmle.label | self [x] | +| capture.swift:204:31:204:34 | self [x] | semmle.label | self [x] | +| capture.swift:205:19:205:26 | ... .some(...) [x] | semmle.label | ... .some(...) [x] | +| capture.swift:205:23:205:26 | self [x] | semmle.label | self [x] | +| capture.swift:205:23:205:26 | self [x] | semmle.label | self [x] | +| capture.swift:206:18:206:21 | self [x] | semmle.label | self [x] | +| capture.swift:206:18:206:23 | ... .x | semmle.label | ... .x | +| capture.swift:207:18:207:18 | x | semmle.label | x | +| capture.swift:213:9:213:9 | x | semmle.label | x | +| capture.swift:213:13:213:25 | source(...) | semmle.label | source(...) | +| capture.swift:214:34:214:37 | self [x] | semmle.label | self [x] | +| capture.swift:214:34:214:37 | self [x] | semmle.label | self [x] | +| capture.swift:215:18:215:21 | self [x] | semmle.label | self [x] | +| capture.swift:215:18:215:23 | ... .x | semmle.label | ... .x | +| capture.swift:216:18:216:18 | x | semmle.label | x | | enums.swift:12:9:12:9 | e [case1.0] | semmle.label | e [case1.0] | | enums.swift:12:13:12:35 | ... .case1(...) [case1.0] | semmle.label | ... .case1(...) [case1.0] | | enums.swift:12:21:12:34 | source(...) | semmle.label | source(...) | @@ -1446,13 +1470,20 @@ testFailures | capture.swift:118:14:118:14 | x | capture.swift:116:13:116:27 | source(...) | capture.swift:118:14:118:14 | x | $@ | capture.swift:116:13:116:27 | source(...) | source(...) | | capture.swift:119:14:119:17 | blah | capture.swift:116:13:116:27 | source(...) | capture.swift:119:14:119:17 | blah | $@ | capture.swift:116:13:116:27 | source(...) | source(...) | | capture.swift:143:14:143:14 | x | capture.swift:147:9:147:23 | source(...) | capture.swift:143:14:143:14 | x | $@ | capture.swift:147:9:147:23 | source(...) | source(...) | -| capture.swift:158:18:158:23 | ... .x | capture.swift:156:13:156:25 | source(...) | capture.swift:158:18:158:23 | ... .x | $@ | capture.swift:156:13:156:25 | source(...) | source(...) | -| capture.swift:166:18:166:23 | ... .x | capture.swift:164:13:164:25 | source(...) | capture.swift:166:18:166:23 | ... .x | $@ | capture.swift:164:13:164:25 | source(...) | source(...) | -| capture.swift:167:18:167:18 | x | capture.swift:164:13:164:25 | source(...) | capture.swift:167:18:167:18 | x | $@ | capture.swift:164:13:164:25 | source(...) | source(...) | -| capture.swift:176:18:176:23 | ... .x | capture.swift:173:13:173:25 | source(...) | capture.swift:176:18:176:23 | ... .x | $@ | capture.swift:173:13:173:25 | source(...) | source(...) | -| capture.swift:177:18:177:18 | x | capture.swift:173:13:173:25 | source(...) | capture.swift:177:18:177:18 | x | $@ | capture.swift:173:13:173:25 | source(...) | source(...) | -| capture.swift:185:18:185:23 | ... .x | capture.swift:183:13:183:25 | source(...) | capture.swift:185:18:185:23 | ... .x | $@ | capture.swift:183:13:183:25 | source(...) | source(...) | -| capture.swift:186:18:186:18 | x | capture.swift:183:13:183:25 | source(...) | capture.swift:186:18:186:18 | x | $@ | capture.swift:183:13:183:25 | source(...) | source(...) | +| capture.swift:154:14:154:15 | $0 | capture.swift:158:13:158:27 | source(...) | capture.swift:154:14:154:15 | $0 | $@ | capture.swift:158:13:158:27 | source(...) | source(...) | +| capture.swift:155:14:155:15 | $1 | capture.swift:158:30:158:44 | source(...) | capture.swift:155:14:155:15 | $1 | $@ | capture.swift:158:30:158:44 | source(...) | source(...) | +| capture.swift:165:18:165:19 | $0 | capture.swift:169:15:169:29 | source(...) | capture.swift:165:18:165:19 | $0 | $@ | capture.swift:169:15:169:29 | source(...) | source(...) | +| capture.swift:166:18:166:19 | $1 | capture.swift:169:32:169:46 | source(...) | capture.swift:166:18:166:19 | $1 | $@ | capture.swift:169:32:169:46 | source(...) | source(...) | +| capture.swift:167:18:167:22 | value | capture.swift:172:11:172:25 | source(...) | capture.swift:167:18:167:22 | value | $@ | capture.swift:172:11:172:25 | source(...) | source(...) | +| capture.swift:170:14:170:15 | $0 | capture.swift:172:11:172:25 | source(...) | capture.swift:170:14:170:15 | $0 | $@ | capture.swift:172:11:172:25 | source(...) | source(...) | +| capture.swift:177:14:177:15 | $1 | capture.swift:179:29:179:43 | source(...) | capture.swift:177:14:177:15 | $1 | $@ | capture.swift:179:29:179:43 | source(...) | source(...) | +| capture.swift:188:18:188:23 | ... .x | capture.swift:186:13:186:25 | source(...) | capture.swift:188:18:188:23 | ... .x | $@ | capture.swift:186:13:186:25 | source(...) | source(...) | +| capture.swift:196:18:196:23 | ... .x | capture.swift:194:13:194:25 | source(...) | capture.swift:196:18:196:23 | ... .x | $@ | capture.swift:194:13:194:25 | source(...) | source(...) | +| capture.swift:197:18:197:18 | x | capture.swift:194:13:194:25 | source(...) | capture.swift:197:18:197:18 | x | $@ | capture.swift:194:13:194:25 | source(...) | source(...) | +| capture.swift:206:18:206:23 | ... .x | capture.swift:203:13:203:25 | source(...) | capture.swift:206:18:206:23 | ... .x | $@ | capture.swift:203:13:203:25 | source(...) | source(...) | +| capture.swift:207:18:207:18 | x | capture.swift:203:13:203:25 | source(...) | capture.swift:207:18:207:18 | x | $@ | capture.swift:203:13:203:25 | source(...) | source(...) | +| capture.swift:215:18:215:23 | ... .x | capture.swift:213:13:213:25 | source(...) | capture.swift:215:18:215:23 | ... .x | $@ | capture.swift:213:13:213:25 | source(...) | source(...) | +| capture.swift:216:18:216:18 | x | capture.swift:213:13:213:25 | source(...) | capture.swift:216:18:216:18 | x | $@ | capture.swift:213:13:213:25 | source(...) | source(...) | | enums.swift:16:14:16:14 | x | enums.swift:12:21:12:34 | source(...) | enums.swift:16:14:16:14 | x | $@ | enums.swift:12:21:12:34 | source(...) | source(...) | | enums.swift:27:14:27:14 | x | enums.swift:23:21:23:34 | source(...) | enums.swift:27:14:27:14 | x | $@ | enums.swift:23:21:23:34 | source(...) | source(...) | | enums.swift:36:10:36:10 | x | enums.swift:34:21:34:34 | source(...) | enums.swift:36:10:36:10 | x | $@ | enums.swift:34:21:34:34 | source(...) | source(...) | diff --git a/unified/ql/test/library-tests/local-name-binding/closures.swift b/unified/ql/test/library-tests/local-name-binding/closures.swift new file mode 100644 index 000000000000..cb5e969fddad --- /dev/null +++ b/unified/ql/test/library-tests/local-name-binding/closures.swift @@ -0,0 +1,28 @@ +func testShorthandParameters() { + let closure = { // implicit-param0=first implicit-param1=second + print($0) // $ access=first + print($0) // $ access=first + print($1) // $ access=second + } + closure(1, 2) // $ access=closure +} + +func testNestedShorthandParameters() { + let outer = { // implicit-param0=outer + print($0) // $ access=outer + let inner = { // implicit-param0=inner0 implicit-param1=inner1 + print($1) // $ access=inner1 + print($0) // $ access=inner0 + } + inner(2, 3) // $ access=inner + print($0) // $ access=outer + } + outer(1) // $ access=outer +} + +func testSkippedShorthandParameter() { + let closure: (Int, Int) -> Void = { // implicit-param1=second + print($1) // $ access=second + } + closure(1, 2) // $ access=closure +} diff --git a/unified/ql/test/library-tests/local-name-binding/test.ql b/unified/ql/test/library-tests/local-name-binding/test.ql index 974322851944..c73aa93c5170 100644 --- a/unified/ql/test/library-tests/local-name-binding/test.ql +++ b/unified/ql/test/library-tests/local-name-binding/test.ql @@ -20,6 +20,8 @@ module VariableAccessTest implements TestSig { else ( // implicit declarations have their own tags v.getName() = "self" and tag = "implicit-self" + or + tag = "implicit-param" + v.getName().regexpCapture("\\$([0-9]+)", 1) ) | keyValueCommentAt(filepath, line, tag, alias) diff --git a/unified/ql/test/library-tests/type-inference/closures.swift b/unified/ql/test/library-tests/type-inference/closures.swift index 3f3f301355b4..3e330a718d96 100644 --- a/unified/ql/test/library-tests/type-inference/closures.swift +++ b/unified/ql/test/library-tests/type-inference/closures.swift @@ -75,3 +75,58 @@ let f: (Box) -> Void = { box in } f(Box()) // $ target=Function.callAsFunction target=Box.init type=Box(...)@Box:Int + +func testShorthandClosureCall() { + let result = apply( + { + String($0) // $ target=String.init type=$0:Int + }, 42) // $ target=apply + _ = result // $ type=result:String +} + +func testSkippedShorthandParameter() { + let result = { + $1 // $ type=$1:String + }(42, "hello") // $ target=Function.callAsFunction + _ = result // $ type=result:String +} + +func testNestedShorthandParameters() { + let result = { + let value = $0 // $ type=$0:Int + let string = { + $1 // $ type=$1:String + }(false, "hello") // $ target=Function.callAsFunction + _ = string // $ type=string:String + return value // $ type=value:Int + }(42) // $ target=Function.callAsFunction + _ = result // $ type=result:Int +} + +func testContextualShorthandParameter() { + let identity: (Int) -> Int = { + $0 // $ type=$0:Int + } + let result = identity(42) // $ target=Function.callAsFunction + _ = result // $ type=result:Int +} + +func testNamedOuterWithShorthandInner(xs: [Int], ys: [Int]) { + let result = xs.map { outer in // $ type=outer:Int + ys.map { + outer + $0 // $ type=outer:Int type=$0:Int + } // $ target=Array.map + } // $ target=Array.map + _ = result // $ type=result:Array type=result@Array:Array +} + +func makeClosureArgument() -> T { + fatalError() +} + +func testReturnContextShorthandParameter() { + let result: String = { + $1 // $ type=$1:String + }(false, makeClosureArgument()) // $ target=Function.callAsFunction target=makeClosureArgument + _ = result // $ type=result:String +} diff --git a/unified/ql/test/library-tests/type-inference/type-inference.expected b/unified/ql/test/library-tests/type-inference/type-inference.expected index 4792825a2f9e..09ed1bab265d 100644 --- a/unified/ql/test/library-tests/type-inference/type-inference.expected +++ b/unified/ql/test/library-tests/type-inference/type-inference.expected @@ -243,6 +243,46 @@ inferCertainType | closures.swift:77:1:77:1 | f | Args.T0 | closures.swift:72:1:72:15 | Box | | closures.swift:77:1:77:1 | f | Args.T0.T | {EXTERNAL LOCATION} | Int | | closures.swift:77:1:77:1 | f | Return | {EXTERNAL LOCATION} | Tuple0 | +| closures.swift:81:9:83:9 | Argument | | {EXTERNAL LOCATION} | Function | +| closures.swift:81:9:83:9 | Argument | Args | {EXTERNAL LOCATION} | Tuple1 | +| closures.swift:81:9:83:9 | FunctionExpr | | {EXTERNAL LOCATION} | Function | +| closures.swift:81:9:83:9 | FunctionExpr | Args | {EXTERNAL LOCATION} | Tuple1 | +| closures.swift:88:18:90:5 | FunctionExpr | | {EXTERNAL LOCATION} | Function | +| closures.swift:88:18:90:5 | FunctionExpr | Args | {EXTERNAL LOCATION} | Tuple2 | +| closures.swift:95:18:102:5 | FunctionExpr | | {EXTERNAL LOCATION} | Function | +| closures.swift:95:18:102:5 | FunctionExpr | Args | {EXTERNAL LOCATION} | Tuple1 | +| closures.swift:97:22:99:9 | FunctionExpr | | {EXTERNAL LOCATION} | Function | +| closures.swift:97:22:99:9 | FunctionExpr | Args | {EXTERNAL LOCATION} | Tuple2 | +| closures.swift:107:9:107:16 | identity | | {EXTERNAL LOCATION} | Function | +| closures.swift:107:9:107:16 | identity | Args | {EXTERNAL LOCATION} | Tuple1 | +| closures.swift:107:9:107:16 | identity | Args.T0 | {EXTERNAL LOCATION} | Int | +| closures.swift:107:9:107:16 | identity | Return | {EXTERNAL LOCATION} | Int | +| closures.swift:107:34:109:5 | FunctionExpr | | {EXTERNAL LOCATION} | Function | +| closures.swift:107:34:109:5 | FunctionExpr | Args | {EXTERNAL LOCATION} | Tuple1 | +| closures.swift:110:18:110:25 | identity | | {EXTERNAL LOCATION} | Function | +| closures.swift:110:18:110:25 | identity | Args | {EXTERNAL LOCATION} | Tuple1 | +| closures.swift:110:18:110:25 | identity | Args.T0 | {EXTERNAL LOCATION} | Int | +| closures.swift:110:18:110:25 | identity | Return | {EXTERNAL LOCATION} | Int | +| closures.swift:114:39:114:40 | xs | | {EXTERNAL LOCATION} | Array | +| closures.swift:114:39:114:40 | xs | Element | {EXTERNAL LOCATION} | Int | +| closures.swift:114:50:114:51 | ys | | {EXTERNAL LOCATION} | Array | +| closures.swift:114:50:114:51 | ys | Element | {EXTERNAL LOCATION} | Int | +| closures.swift:115:18:115:19 | xs | | {EXTERNAL LOCATION} | Array | +| closures.swift:115:18:115:19 | xs | Element | {EXTERNAL LOCATION} | Int | +| closures.swift:115:25:119:5 | Argument | | {EXTERNAL LOCATION} | Function | +| closures.swift:115:25:119:5 | Argument | Args | {EXTERNAL LOCATION} | Tuple1 | +| closures.swift:115:25:119:5 | FunctionExpr | | {EXTERNAL LOCATION} | Function | +| closures.swift:115:25:119:5 | FunctionExpr | Args | {EXTERNAL LOCATION} | Tuple1 | +| closures.swift:116:9:116:10 | ys | | {EXTERNAL LOCATION} | Array | +| closures.swift:116:9:116:10 | ys | Element | {EXTERNAL LOCATION} | Int | +| closures.swift:116:16:118:9 | Argument | | {EXTERNAL LOCATION} | Function | +| closures.swift:116:16:118:9 | Argument | Args | {EXTERNAL LOCATION} | Tuple1 | +| closures.swift:116:16:118:9 | FunctionExpr | | {EXTERNAL LOCATION} | Function | +| closures.swift:116:16:118:9 | FunctionExpr | Args | {EXTERNAL LOCATION} | Tuple1 | +| closures.swift:128:9:128:14 | result | | {EXTERNAL LOCATION} | String | +| closures.swift:128:26:130:5 | FunctionExpr | | {EXTERNAL LOCATION} | Function | +| closures.swift:128:26:130:5 | FunctionExpr | Args | {EXTERNAL LOCATION} | Tuple2 | +| closures.swift:131:9:131:14 | result | | {EXTERNAL LOCATION} | String | | constructors.swift:2:12:2:12 | x | | {EXTERNAL LOCATION} | Int | | constructors.swift:5:9:5:12 | self | | constructors.swift:1:1:7:1 | C1 | | constructors.swift:24:12:24:12 | x | | {EXTERNAL LOCATION} | Int | @@ -266,6 +306,7 @@ inferCertainType | constructors.swift:71:9:71:10 | f3 | Args.T0 | constructors.swift:68:11:68:11 | T | | constructors.swift:71:9:71:10 | f3 | Return | constructors.swift:68:11:68:11 | T | | constructors.swift:71:24:71:29 | FunctionExpr | | {EXTERNAL LOCATION} | Function | +| constructors.swift:71:24:71:29 | FunctionExpr | Args | {EXTERNAL LOCATION} | Tuple1 | | constructors.swift:76:19:76:32 | Argument | | {EXTERNAL LOCATION} | Function | | constructors.swift:76:19:76:32 | Argument | Args | {EXTERNAL LOCATION} | Tuple1 | | constructors.swift:76:23:76:32 | FunctionExpr | | {EXTERNAL LOCATION} | Function | @@ -479,7 +520,9 @@ inferCertainType | key_paths.swift:99:10:99:14 | items | | {EXTERNAL LOCATION} | Array | | key_paths.swift:99:10:99:14 | items | Element | key_paths.swift:98:19:98:19 | T | | key_paths.swift:99:20:99:43 | Argument | | {EXTERNAL LOCATION} | Function | +| key_paths.swift:99:20:99:43 | Argument | Args | {EXTERNAL LOCATION} | Tuple1 | | key_paths.swift:99:20:99:43 | FunctionExpr | | {EXTERNAL LOCATION} | Function | +| key_paths.swift:99:20:99:43 | FunctionExpr | Args | {EXTERNAL LOCATION} | Tuple1 | | key_paths.swift:99:25:99:40 | Argument | unknown type parameter 0 | key_paths.swift:98:19:98:19 | T | | key_paths.swift:99:25:99:40 | Argument | unknown type parameter 1 | key_paths.swift:98:22:98:22 | V | | key_paths.swift:99:34:99:40 | keyPath | unknown type parameter 0 | key_paths.swift:98:19:98:19 | T | @@ -1309,7 +1352,9 @@ inferCertainType | type_constraints.swift:208:12:208:17 | values | | {EXTERNAL LOCATION} | Array | | type_constraints.swift:208:12:208:17 | values | Element | type_constraints.swift:200:20:200:20 | T | | type_constraints.swift:220:28:222:5 | Argument | | {EXTERNAL LOCATION} | Function | +| type_constraints.swift:220:28:222:5 | Argument | Args | {EXTERNAL LOCATION} | Tuple1 | | type_constraints.swift:220:35:222:5 | FunctionExpr | | {EXTERNAL LOCATION} | Function | +| type_constraints.swift:220:35:222:5 | FunctionExpr | Args | {EXTERNAL LOCATION} | Tuple1 | | type_constraints.swift:227:28:227:44 | Argument | | {EXTERNAL LOCATION} | Array | | type_constraints.swift:227:36:227:44 | ArrayLiteral | | {EXTERNAL LOCATION} | Array | | type_constraints.swift:236:33:236:37 | items | | {EXTERNAL LOCATION} | Array | @@ -1911,7 +1956,6 @@ inferType | classes.swift:198:7:198:9 | val | | {EXTERNAL LOCATION} | Int | | classes.swift:198:13:198:15 | ctr | | classes.swift:183:1:193:1 | Counter | | classes.swift:198:13:198:26 | ... .getCount(...) | | {EXTERNAL LOCATION} | Int | -| closures.swift:1:1:77:8 | Block | | {EXTERNAL LOCATION} | Tuple0 | | closures.swift:1:32:7:1 | Block | | {EXTERNAL LOCATION} | Int | | closures.swift:2:9:2:14 | addOne | | {EXTERNAL LOCATION} | Function | | closures.swift:2:9:2:14 | addOne | Args | {EXTERNAL LOCATION} | Tuple1 | @@ -2145,6 +2189,168 @@ inferType | closures.swift:77:3:77:7 | Argument | T | {EXTERNAL LOCATION} | Int | | closures.swift:77:3:77:7 | Box(...) | | closures.swift:72:1:72:15 | Box | | closures.swift:77:3:77:7 | Box(...) | T | {EXTERNAL LOCATION} | Int | +| closures.swift:79:33:85:1 | Block | | {EXTERNAL LOCATION} | String | +| closures.swift:80:9:80:14 | result | | {EXTERNAL LOCATION} | String | +| closures.swift:80:18:83:14 | apply(...) | | {EXTERNAL LOCATION} | String | +| closures.swift:81:9:83:9 | Argument | | {EXTERNAL LOCATION} | Function | +| closures.swift:81:9:83:9 | Argument | Args | {EXTERNAL LOCATION} | Tuple1 | +| closures.swift:81:9:83:9 | Argument | Args.T0 | {EXTERNAL LOCATION} | Int | +| closures.swift:81:9:83:9 | Argument | Return | {EXTERNAL LOCATION} | String | +| closures.swift:81:9:83:9 | FunctionExpr | | {EXTERNAL LOCATION} | Function | +| closures.swift:81:9:83:9 | FunctionExpr | Args | {EXTERNAL LOCATION} | Tuple1 | +| closures.swift:81:9:83:9 | FunctionExpr | Args.T0 | {EXTERNAL LOCATION} | Int | +| closures.swift:81:9:83:9 | FunctionExpr | Return | {EXTERNAL LOCATION} | String | +| closures.swift:82:13:82:18 | String | | {EXTERNAL LOCATION} | String | +| closures.swift:82:13:82:22 | Block | | {EXTERNAL LOCATION} | String | +| closures.swift:82:13:82:22 | String(...) | | {EXTERNAL LOCATION} | String | +| closures.swift:82:20:82:21 | $0 | | {EXTERNAL LOCATION} | Int | +| closures.swift:82:20:82:21 | Argument | | {EXTERNAL LOCATION} | Int | +| closures.swift:83:12:83:13 | 42 | | {EXTERNAL LOCATION} | Int | +| closures.swift:83:12:83:13 | Argument | | {EXTERNAL LOCATION} | Int | +| closures.swift:84:5:84:5 | _ | | {EXTERNAL LOCATION} | String | +| closures.swift:84:5:84:14 | ... = ... | | {EXTERNAL LOCATION} | String | +| closures.swift:84:9:84:14 | result | | {EXTERNAL LOCATION} | String | +| closures.swift:87:38:92:1 | Block | | {EXTERNAL LOCATION} | String | +| closures.swift:88:9:88:14 | result | | {EXTERNAL LOCATION} | String | +| closures.swift:88:18:90:5 | FunctionExpr | | {EXTERNAL LOCATION} | Function | +| closures.swift:88:18:90:5 | FunctionExpr | Args | {EXTERNAL LOCATION} | Tuple2 | +| closures.swift:88:18:90:5 | FunctionExpr | Args.T0 | {EXTERNAL LOCATION} | Int | +| closures.swift:88:18:90:5 | FunctionExpr | Args.T1 | {EXTERNAL LOCATION} | String | +| closures.swift:88:18:90:5 | FunctionExpr | Return | {EXTERNAL LOCATION} | String | +| closures.swift:88:18:90:18 | ...(...) | | {EXTERNAL LOCATION} | String | +| closures.swift:89:9:89:10 | $1 | | {EXTERNAL LOCATION} | String | +| closures.swift:89:9:89:10 | Block | | {EXTERNAL LOCATION} | String | +| closures.swift:90:7:90:8 | 42 | | {EXTERNAL LOCATION} | Int | +| closures.swift:90:7:90:8 | Argument | | {EXTERNAL LOCATION} | Int | +| closures.swift:90:11:90:17 | "hello" | | {EXTERNAL LOCATION} | String | +| closures.swift:90:11:90:17 | Argument | | {EXTERNAL LOCATION} | String | +| closures.swift:91:5:91:5 | _ | | {EXTERNAL LOCATION} | String | +| closures.swift:91:5:91:14 | ... = ... | | {EXTERNAL LOCATION} | String | +| closures.swift:91:9:91:14 | result | | {EXTERNAL LOCATION} | String | +| closures.swift:94:38:104:1 | Block | | {EXTERNAL LOCATION} | Int | +| closures.swift:95:9:95:14 | result | | {EXTERNAL LOCATION} | Int | +| closures.swift:95:18:102:5 | FunctionExpr | | {EXTERNAL LOCATION} | Function | +| closures.swift:95:18:102:5 | FunctionExpr | Args | {EXTERNAL LOCATION} | Tuple1 | +| closures.swift:95:18:102:5 | FunctionExpr | Args.T0 | {EXTERNAL LOCATION} | Int | +| closures.swift:95:18:102:5 | FunctionExpr | Return | {EXTERNAL LOCATION} | Int | +| closures.swift:95:18:102:9 | ...(...) | | {EXTERNAL LOCATION} | Int | +| closures.swift:96:9:101:20 | Block | | {EXTERNAL LOCATION} | Int | +| closures.swift:96:13:96:17 | value | | {EXTERNAL LOCATION} | Int | +| closures.swift:96:21:96:22 | $0 | | {EXTERNAL LOCATION} | Int | +| closures.swift:97:13:97:18 | string | | {EXTERNAL LOCATION} | String | +| closures.swift:97:22:99:9 | FunctionExpr | | {EXTERNAL LOCATION} | Function | +| closures.swift:97:22:99:9 | FunctionExpr | Args | {EXTERNAL LOCATION} | Tuple2 | +| closures.swift:97:22:99:9 | FunctionExpr | Args.T0 | {EXTERNAL LOCATION} | Bool | +| closures.swift:97:22:99:9 | FunctionExpr | Args.T1 | {EXTERNAL LOCATION} | String | +| closures.swift:97:22:99:9 | FunctionExpr | Return | {EXTERNAL LOCATION} | String | +| closures.swift:97:22:99:25 | ...(...) | | {EXTERNAL LOCATION} | String | +| closures.swift:98:13:98:14 | $1 | | {EXTERNAL LOCATION} | String | +| closures.swift:98:13:98:14 | Block | | {EXTERNAL LOCATION} | String | +| closures.swift:99:11:99:15 | Argument | | {EXTERNAL LOCATION} | Bool | +| closures.swift:99:11:99:15 | false | | {EXTERNAL LOCATION} | Bool | +| closures.swift:99:18:99:24 | "hello" | | {EXTERNAL LOCATION} | String | +| closures.swift:99:18:99:24 | Argument | | {EXTERNAL LOCATION} | String | +| closures.swift:100:9:100:9 | _ | | {EXTERNAL LOCATION} | String | +| closures.swift:100:9:100:18 | ... = ... | | {EXTERNAL LOCATION} | String | +| closures.swift:100:13:100:18 | string | | {EXTERNAL LOCATION} | String | +| closures.swift:101:16:101:20 | value | | {EXTERNAL LOCATION} | Int | +| closures.swift:102:7:102:8 | 42 | | {EXTERNAL LOCATION} | Int | +| closures.swift:102:7:102:8 | Argument | | {EXTERNAL LOCATION} | Int | +| closures.swift:103:5:103:5 | _ | | {EXTERNAL LOCATION} | Int | +| closures.swift:103:5:103:14 | ... = ... | | {EXTERNAL LOCATION} | Int | +| closures.swift:103:9:103:14 | result | | {EXTERNAL LOCATION} | Int | +| closures.swift:106:41:112:1 | Block | | {EXTERNAL LOCATION} | Int | +| closures.swift:107:9:107:16 | identity | | {EXTERNAL LOCATION} | Function | +| closures.swift:107:9:107:16 | identity | Args | {EXTERNAL LOCATION} | Tuple1 | +| closures.swift:107:9:107:16 | identity | Args.T0 | {EXTERNAL LOCATION} | Int | +| closures.swift:107:9:107:16 | identity | Return | {EXTERNAL LOCATION} | Int | +| closures.swift:107:34:109:5 | FunctionExpr | | {EXTERNAL LOCATION} | Function | +| closures.swift:107:34:109:5 | FunctionExpr | Args | {EXTERNAL LOCATION} | Tuple1 | +| closures.swift:107:34:109:5 | FunctionExpr | Args.T0 | {EXTERNAL LOCATION} | Int | +| closures.swift:107:34:109:5 | FunctionExpr | Return | {EXTERNAL LOCATION} | Int | +| closures.swift:108:9:108:10 | $0 | | {EXTERNAL LOCATION} | Int | +| closures.swift:108:9:108:10 | Block | | {EXTERNAL LOCATION} | Int | +| closures.swift:110:9:110:14 | result | | {EXTERNAL LOCATION} | Int | +| closures.swift:110:18:110:25 | identity | | {EXTERNAL LOCATION} | Function | +| closures.swift:110:18:110:25 | identity | Args | {EXTERNAL LOCATION} | Tuple1 | +| closures.swift:110:18:110:25 | identity | Args.T0 | {EXTERNAL LOCATION} | Int | +| closures.swift:110:18:110:25 | identity | Return | {EXTERNAL LOCATION} | Int | +| closures.swift:110:18:110:29 | identity(...) | | {EXTERNAL LOCATION} | Int | +| closures.swift:110:27:110:28 | 42 | | {EXTERNAL LOCATION} | Int | +| closures.swift:110:27:110:28 | Argument | | {EXTERNAL LOCATION} | Int | +| closures.swift:111:5:111:5 | _ | | {EXTERNAL LOCATION} | Int | +| closures.swift:111:5:111:14 | ... = ... | | {EXTERNAL LOCATION} | Int | +| closures.swift:111:9:111:14 | result | | {EXTERNAL LOCATION} | Int | +| closures.swift:114:39:114:40 | xs | | {EXTERNAL LOCATION} | Array | +| closures.swift:114:39:114:40 | xs | Element | {EXTERNAL LOCATION} | Int | +| closures.swift:114:50:114:51 | ys | | {EXTERNAL LOCATION} | Array | +| closures.swift:114:50:114:51 | ys | Element | {EXTERNAL LOCATION} | Int | +| closures.swift:114:61:121:1 | Block | | {EXTERNAL LOCATION} | Array | +| closures.swift:114:61:121:1 | Block | Element | {EXTERNAL LOCATION} | Array | +| closures.swift:114:61:121:1 | Block | Element.Element | {EXTERNAL LOCATION} | Int | +| closures.swift:115:9:115:14 | result | | {EXTERNAL LOCATION} | Array | +| closures.swift:115:9:115:14 | result | Element | {EXTERNAL LOCATION} | Array | +| closures.swift:115:9:115:14 | result | Element.Element | {EXTERNAL LOCATION} | Int | +| closures.swift:115:18:115:19 | xs | | {EXTERNAL LOCATION} | Array | +| closures.swift:115:18:115:19 | xs | Element | {EXTERNAL LOCATION} | Int | +| closures.swift:115:18:119:5 | ... .map(...) | | {EXTERNAL LOCATION} | Array | +| closures.swift:115:18:119:5 | ... .map(...) | Element | {EXTERNAL LOCATION} | Array | +| closures.swift:115:18:119:5 | ... .map(...) | Element.Element | {EXTERNAL LOCATION} | Int | +| closures.swift:115:25:119:5 | Argument | | {EXTERNAL LOCATION} | Function | +| closures.swift:115:25:119:5 | Argument | Args | {EXTERNAL LOCATION} | Tuple1 | +| closures.swift:115:25:119:5 | Argument | Args.T0 | {EXTERNAL LOCATION} | Int | +| closures.swift:115:25:119:5 | Argument | Return | {EXTERNAL LOCATION} | Array | +| closures.swift:115:25:119:5 | Argument | Return.Element | {EXTERNAL LOCATION} | Int | +| closures.swift:115:25:119:5 | FunctionExpr | | {EXTERNAL LOCATION} | Function | +| closures.swift:115:25:119:5 | FunctionExpr | Args | {EXTERNAL LOCATION} | Tuple1 | +| closures.swift:115:25:119:5 | FunctionExpr | Args.T0 | {EXTERNAL LOCATION} | Int | +| closures.swift:115:25:119:5 | FunctionExpr | Return | {EXTERNAL LOCATION} | Array | +| closures.swift:115:25:119:5 | FunctionExpr | Return.Element | {EXTERNAL LOCATION} | Int | +| closures.swift:115:27:115:31 | outer | | {EXTERNAL LOCATION} | Int | +| closures.swift:116:9:116:10 | ys | | {EXTERNAL LOCATION} | Array | +| closures.swift:116:9:116:10 | ys | Element | {EXTERNAL LOCATION} | Int | +| closures.swift:116:9:118:9 | ... .map(...) | | {EXTERNAL LOCATION} | Array | +| closures.swift:116:9:118:9 | ... .map(...) | Element | {EXTERNAL LOCATION} | Int | +| closures.swift:116:9:118:9 | Block | | {EXTERNAL LOCATION} | Array | +| closures.swift:116:9:118:9 | Block | Element | {EXTERNAL LOCATION} | Int | +| closures.swift:116:16:118:9 | Argument | | {EXTERNAL LOCATION} | Function | +| closures.swift:116:16:118:9 | Argument | Args | {EXTERNAL LOCATION} | Tuple1 | +| closures.swift:116:16:118:9 | Argument | Args.T0 | {EXTERNAL LOCATION} | Int | +| closures.swift:116:16:118:9 | Argument | Return | {EXTERNAL LOCATION} | Int | +| closures.swift:116:16:118:9 | FunctionExpr | | {EXTERNAL LOCATION} | Function | +| closures.swift:116:16:118:9 | FunctionExpr | Args | {EXTERNAL LOCATION} | Tuple1 | +| closures.swift:116:16:118:9 | FunctionExpr | Args.T0 | {EXTERNAL LOCATION} | Int | +| closures.swift:116:16:118:9 | FunctionExpr | Return | {EXTERNAL LOCATION} | Int | +| closures.swift:117:13:117:17 | outer | | {EXTERNAL LOCATION} | Int | +| closures.swift:117:13:117:22 | ... + ... | | {EXTERNAL LOCATION} | Int | +| closures.swift:117:13:117:22 | Block | | {EXTERNAL LOCATION} | Int | +| closures.swift:117:21:117:22 | $0 | | {EXTERNAL LOCATION} | Int | +| closures.swift:120:5:120:5 | _ | | {EXTERNAL LOCATION} | Array | +| closures.swift:120:5:120:5 | _ | Element | {EXTERNAL LOCATION} | Array | +| closures.swift:120:5:120:5 | _ | Element.Element | {EXTERNAL LOCATION} | Int | +| closures.swift:120:5:120:14 | ... = ... | | {EXTERNAL LOCATION} | Array | +| closures.swift:120:5:120:14 | ... = ... | Element | {EXTERNAL LOCATION} | Array | +| closures.swift:120:5:120:14 | ... = ... | Element.Element | {EXTERNAL LOCATION} | Int | +| closures.swift:120:9:120:14 | result | | {EXTERNAL LOCATION} | Array | +| closures.swift:120:9:120:14 | result | Element | {EXTERNAL LOCATION} | Array | +| closures.swift:120:9:120:14 | result | Element.Element | {EXTERNAL LOCATION} | Int | +| closures.swift:127:44:132:1 | Block | | {EXTERNAL LOCATION} | String | +| closures.swift:128:9:128:14 | result | | {EXTERNAL LOCATION} | String | +| closures.swift:128:26:130:5 | FunctionExpr | | {EXTERNAL LOCATION} | Function | +| closures.swift:128:26:130:5 | FunctionExpr | Args | {EXTERNAL LOCATION} | Tuple2 | +| closures.swift:128:26:130:5 | FunctionExpr | Args.T0 | {EXTERNAL LOCATION} | Bool | +| closures.swift:128:26:130:5 | FunctionExpr | Args.T1 | {EXTERNAL LOCATION} | String | +| closures.swift:128:26:130:5 | FunctionExpr | Return | {EXTERNAL LOCATION} | String | +| closures.swift:128:26:130:35 | ...(...) | | {EXTERNAL LOCATION} | String | +| closures.swift:129:9:129:10 | $1 | | {EXTERNAL LOCATION} | String | +| closures.swift:129:9:129:10 | Block | | {EXTERNAL LOCATION} | String | +| closures.swift:130:7:130:11 | Argument | | {EXTERNAL LOCATION} | Bool | +| closures.swift:130:7:130:11 | false | | {EXTERNAL LOCATION} | Bool | +| closures.swift:130:14:130:34 | Argument | | {EXTERNAL LOCATION} | String | +| closures.swift:130:14:130:34 | makeClosureArgument(...) | | {EXTERNAL LOCATION} | String | +| closures.swift:131:5:131:5 | _ | | {EXTERNAL LOCATION} | String | +| closures.swift:131:5:131:14 | ... = ... | | {EXTERNAL LOCATION} | String | +| closures.swift:131:9:131:14 | result | | {EXTERNAL LOCATION} | String | | constructors.swift:2:12:2:12 | x | | {EXTERNAL LOCATION} | Int | | constructors.swift:4:24:6:5 | Block | | constructors.swift:1:1:7:1 | C1 | | constructors.swift:5:9:5:12 | self | | constructors.swift:1:1:7:1 | C1 | @@ -2254,6 +2460,11 @@ inferType | constructors.swift:71:9:71:10 | f3 | Args.T0 | constructors.swift:68:11:68:11 | T | | constructors.swift:71:9:71:10 | f3 | Return | constructors.swift:68:11:68:11 | T | | constructors.swift:71:24:71:29 | FunctionExpr | | {EXTERNAL LOCATION} | Function | +| constructors.swift:71:24:71:29 | FunctionExpr | Args | {EXTERNAL LOCATION} | Tuple1 | +| constructors.swift:71:24:71:29 | FunctionExpr | Args.T0 | constructors.swift:68:11:68:11 | T | +| constructors.swift:71:24:71:29 | FunctionExpr | Return | constructors.swift:68:11:68:11 | T | +| constructors.swift:71:26:71:27 | $0 | | constructors.swift:68:11:68:11 | T | +| constructors.swift:71:26:71:27 | Block | | constructors.swift:68:11:68:11 | T | | constructors.swift:74:5:74:7 | s11 | | constructors.swift:68:1:72:1 | S1 | | constructors.swift:74:5:74:7 | s11 | T | {EXTERNAL LOCATION} | Int | | constructors.swift:74:11:74:12 | S1 | | constructors.swift:68:1:72:1 | S1 | @@ -3030,7 +3241,12 @@ inferType | key_paths.swift:99:10:99:14 | items | Element | key_paths.swift:98:19:98:19 | T | | key_paths.swift:99:10:99:43 | ... .map(...) | | {EXTERNAL LOCATION} | Array | | key_paths.swift:99:20:99:43 | Argument | | {EXTERNAL LOCATION} | Function | +| key_paths.swift:99:20:99:43 | Argument | Args | {EXTERNAL LOCATION} | Tuple1 | +| key_paths.swift:99:20:99:43 | Argument | Args.T0 | key_paths.swift:98:19:98:19 | T | | key_paths.swift:99:20:99:43 | FunctionExpr | | {EXTERNAL LOCATION} | Function | +| key_paths.swift:99:20:99:43 | FunctionExpr | Args | {EXTERNAL LOCATION} | Tuple1 | +| key_paths.swift:99:20:99:43 | FunctionExpr | Args.T0 | key_paths.swift:98:19:98:19 | T | +| key_paths.swift:99:22:99:23 | $0 | | key_paths.swift:98:19:98:19 | T | | key_paths.swift:99:25:99:40 | Argument | unknown type parameter 0 | key_paths.swift:98:19:98:19 | T | | key_paths.swift:99:25:99:40 | Argument | unknown type parameter 1 | key_paths.swift:98:22:98:22 | V | | key_paths.swift:99:34:99:40 | keyPath | unknown type parameter 0 | key_paths.swift:98:19:98:19 | T | @@ -5503,7 +5719,9 @@ inferType | type_constraints.swift:220:12:220:17 | values | | {EXTERNAL LOCATION} | Array | | type_constraints.swift:220:12:220:17 | values | Element | type_constraints.swift:200:20:200:20 | T | | type_constraints.swift:220:28:222:5 | Argument | | {EXTERNAL LOCATION} | Function | +| type_constraints.swift:220:28:222:5 | Argument | Args | {EXTERNAL LOCATION} | Tuple1 | | type_constraints.swift:220:35:222:5 | FunctionExpr | | {EXTERNAL LOCATION} | Function | +| type_constraints.swift:220:35:222:5 | FunctionExpr | Args | {EXTERNAL LOCATION} | Tuple1 | | type_constraints.swift:227:7:227:12 | intAcc | | type_constraints.swift:200:1:210:1 | Accumulator | | type_constraints.swift:227:7:227:12 | intAcc | T | {EXTERNAL LOCATION} | Int | | type_constraints.swift:227:16:227:26 | Accumulator | | type_constraints.swift:200:1:210:1 | Accumulator |