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-5715] Invalid diagnostics and fixits referencing static value in nested exception #48285

Closed
NachoSoto opened this issue Aug 18, 2017 · 2 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation type checker Area → compiler: Semantic analysis

Comments

@NachoSoto
Copy link
Contributor

Previous ID SR-5715
Radar rdar://problem/33968154
Original Reporter @NachoSoto
Type Bug
Status Resolved
Resolution Done
Environment
  • Swift version 3.1 (swiftlang-802.0.53 clang-802.0.42)

  • Swift version 4.0 (swiftlang-900.0.59 clang-900.0.34.2)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DiagnosticsQoI, TypeChecker
Assignee @NachoSoto
Priority Medium

md5: 281e55968bd065aa6bc52027267ecada

Issue Description:

Consider these structs:

struct A {
  struct B {
    struct C {}
  }
}

Adding a function to C:

extension A.B.C {
  private static let x: Int = 0

  func f() -> Int {
    return x
  }
}

Produces an invalid fix it:

error: repl.swift:10:16: error: static member 'x' cannot be used on instance of type 'A.B.C'
        return x
               ^
               C.

Applying the fix it results in invalid code, and an invalid fixit:

extension A.B.C {
  private static let x: Int = 0

  func f() -> Int {
    return C.x
  }
}

repl.swift:9:10: note: did you mean 'f'?
    func f() -> Int {
         ^

Using a property produces the wrong fix it too:

extension A.B.C {
    private static let x: Int = 0

    var f: Int {
        return x
    }
}
error: repl.swift:11:16: error: static member 'x' cannot be used on instance of type 'A.B.C'
        return x
               ^
               C.

But the error after applying it is correct:

error: repl.swift:10:16: error: use of unresolved identifier 'C'
        return C.x
               ^
@jckarter
Copy link
Member

@swift-ci create

@xedin
Copy link
Member

xedin commented Feb 5, 2020

Looks like by porting shadowing diagnostics I have fixed this one as well, how both cases suggest `A.B.C.` instead of just `C.`. Please use the latest nightly snapshot to verify and close.

@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. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants