Skip to content
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

[SR-7219] SourceKit returns wrong structure for capture groups #49767

Closed
marcelofabri opened this issue Mar 18, 2018 · 3 comments
Closed

[SR-7219] SourceKit returns wrong structure for capture groups #49767

marcelofabri opened this issue Mar 18, 2018 · 3 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@marcelofabri
Copy link
Contributor

Previous ID SR-7219
Radar None
Original Reporter @marcelofabri
Type Bug
Status Closed
Resolution Cannot Reproduce
Environment

Apple Swift version 4.1 (swiftlang-902.0.43 clang-902.0.37.1)

Target: x86_64-apple-darwin17.4.0

Additional Detail from JIRA
Votes 0
Component/s Source Tooling
Labels Bug
Assignee None
Priority Medium

md5: e5c6968940d92d40c58dc87e9178899a

Issue Description:

SourceKit is returning duplicate variable declarations for variables declared in a capture group. It also reports wrong key.length and key.body for the unowned attribute.

Sample code:

foo() { [unowned self] in _ }()

SourceKit response:

{
  "key.diagnostic_stage" : "source.diagnostic.stage.swift.parse",
  "key.length" : 31,
  "key.offset" : 0,
  "key.substructure" : [
    {
      "key.bodylength" : 0,
      "key.bodyoffset" : 30,
      "key.kind" : "source.lang.swift.expr.call",
      "key.length" : 31,
      "key.name" : "foo() { [unowned self] in _ }",
      "key.namelength" : 29,
      "key.nameoffset" : 0,
      "key.offset" : 0,
      "key.substructure" : [
        {
          "key.bodylength" : 24,
          "key.bodyoffset" : 4,
          "key.kind" : "source.lang.swift.expr.call",
          "key.length" : 29,
          "key.name" : "foo",
          "key.namelength" : 3,
          "key.nameoffset" : 0,
          "key.offset" : 0,
          "key.substructure" : [
            {
              "key.attributes" : [
                {
                  "key.attribute" : "source.decl.attribute.weak",
                  "key.length" : 0,
                  "key.offset" : 0
                }
              ],
              "key.kind" : "source.lang.swift.decl.var.local",
              "key.length" : 4,
              "key.name" : "self",
              "key.namelength" : 4,
              "key.nameoffset" : 17,
              "key.offset" : 17
            },
            {
              "key.attributes" : [
                {
                  "key.attribute" : "source.decl.attribute.weak",
                  "key.length" : 0,
                  "key.offset" : 0
                }
              ],
              "key.kind" : "source.lang.swift.decl.var.local",
              "key.length" : 4,
              "key.name" : "self",
              "key.namelength" : 4,
              "key.nameoffset" : 17,
              "key.offset" : 17
            }
          ]
        }
      ]
    }
  ]
}
@marcelofabri
Copy link
Contributor Author

This seems to be fixed on `master`, but not on Swift 4.2. Can someone else please double check?

@marcelofabri
Copy link
Contributor Author

Just confirmed that it's fixed on swift-DEVELOPMENT-SNAPSHOT-2018-08-25-a, but the issue still happens on swift-4.2-DEVELOPMENT-SNAPSHOT-2018-08-25-a.

@marcelofabri
Copy link
Contributor Author

Fixed on master.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.
Projects
None yet
Development

No branches or pull requests

1 participant