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

explicit_type_interface rule triggered in case let switches #2154

Closed
Hans92 opened this issue Apr 13, 2018 · 6 comments · Fixed by #2588
Closed

explicit_type_interface rule triggered in case let switches #2154

Hans92 opened this issue Apr 13, 2018 · 6 comments · Fixed by #2588
Labels
bug Unexpected and reproducible misbehavior.

Comments

@Hans92
Copy link

Hans92 commented Apr 13, 2018

Xcode 9.3 (9E145)
Swiflint 0.25.1

struct SomeError: Error { }
struct SomeError1: Error { }

let error: Error = Error()

switch error {
	case let error as SomeError:
		// some code
	case let error as SomeError1:
		// some code
}

On every case line I get an error:
"Explicit Type Interface Violation: Properties should have a type interface (explicit_type_interface)".
I can't add here error type. Swift doesn't get it.

I am not sure if this is a bug or I'm doing something wrong.

@marcelofabri
Copy link
Collaborator

Maybe we should ignore variables inside cases (source.lang.swift.stmt.case)?

This is the structure that SourceKit returns:

{
          "key.elements" : [
            {
              "key.kind" : "source.lang.swift.structure.elem.pattern",
              "key.length" : 23,
              "key.offset" : 164
            }
          ],
          "key.kind" : "source.lang.swift.stmt.case",
          "key.length" : 29,
          "key.namelength" : 0,
          "key.nameoffset" : 0,
          "key.offset" : 159,
          "key.substructure" : [
            {
              "key.kind" : "source.lang.swift.decl.var.local",
              "key.length" : 5,
              "key.name" : "error",
              "key.namelength" : 5,
              "key.nameoffset" : 168,
              "key.offset" : 168
            }
          ]
        }

@marcelofabri marcelofabri added the bug Unexpected and reproducible misbehavior. label Apr 13, 2018
@Hans92
Copy link
Author

Hans92 commented Apr 18, 2018

There is also a problem with [weak self] in closures.

@marcelofabri
Copy link
Collaborator

Feel free to send a PR!

@ppamorim
Copy link

ppamorim commented Jun 8, 2018

There is a error on case .failure(let error):, Swiftlint warns to set a type, but it is not possible.

@Pikacz
Copy link

Pikacz commented May 9, 2019

There is still error on case X.value(let val) but not on case .value(let val)

@ppamorim
Copy link

@marcelofabri Any type of regression on this? I am getting this error again on 0.43.1.

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

Successfully merging a pull request may close this issue.

4 participants