Skip to content

[Swift 5.5] Special-case Pattern Binding Decls Created by LLDB #3043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 16, 2021

Conversation

CodaFi
Copy link

@CodaFi CodaFi commented Jun 14, 2021

Cherry pick #3020


When LLDB wraps a user-defined expression in the REPL, it takes something like this

<expr>

and turns it into (very very abstractly)

var result
do {
  result = <expr>
}
print(result)

In the process, it creates an implicit pattern binding and an implicit do block. Of these, only the implicit do is considered by ASTScope lookup to be relevant. This presents a problem when is or contains a closure, as the parameters of that closure are defined within a scope that will never be expanded. Thus,

> [42].map { x in x } // <- cannot find 'x' in scope

This patch provides the LLDB half of the fix wherein we consume the
infrastructure in the Swift half and readjust the source locations of
the implicit braced block so ASTScope is happy to look up variables
defined in its body.

rdar://72160854

CodaFi added 2 commits June 14, 2021 14:49
When LLDB wraps a user-defined expression in the REPL, it takes something like this
```
<expr>
```

and turns it into (very very abstractly)

```
var result
do {
  result = <expr>
}
print(result)
```

In the process, it creates an implicit pattern binding and an implicit do block. Of these, only the implicit do is considered by ASTScope lookup to be relevant. This presents a problem when <expr> is or contains a closure, as the parameters of that closure are defined within a scope that will never be expanded. Thus,

```
> [42].map { x in x } // <- cannot find 'x' in scope
```

This patch provides the LLDB half of the fix wherein we consume the
infrastructure in the Swift half and readjust the source locations of
the implicit braced block so ASTScope is happy to look up variables
defined in its body.

rdar://78256873
@CodaFi
Copy link
Author

CodaFi commented Jun 14, 2021

swiftlang/swift#37909

@swift-ci please test

@CodaFi
Copy link
Author

CodaFi commented Jun 16, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant