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

Invalid type leads to "Failed to produce diagnostic for expression" #77644

Open
hamishknight opened this issue Nov 15, 2024 · 0 comments · May be fixed by #77652
Open

Invalid type leads to "Failed to produce diagnostic for expression" #77644

hamishknight opened this issue Nov 15, 2024 · 0 comments · May be fixed by #77652
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself diagnostics QoI Bug: Diagnostics Quality of Implementation type checker Area → compiler: Semantic analysis

Comments

@hamishknight
Copy link
Contributor

hamishknight commented Nov 15, 2024

The following test case (added in #77643) incorrectly produces failed to produce diagnostic for expression:

func bar(_ x: Int.Type, _: Int) {}
func bar<T>(_ x: T.Type, _: Int) {}

func foo() {
  bar(X<Int?>.self, .zero)
  // expected-error@-1 {{cannot find 'X' in scope}}
  // expected-error@-2 {{failed to produce diagnostic for expression}}
}

Looks like we're ending up with a leftover inactive constraint:

(failed due to remaining inactive constraints:
  $T1 explicit generic argument binding Pack{Int?} @ locator@0x1378873a8 [Error@/Users/hamish/src/swift-test-arena/main.swift:608:7]
)

Swift version 6.1-dev (LLVM 834e05aeccee532, Swift 45d15d1)
Target: arm64-apple-macosx15.0

@hamishknight hamishknight added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself diagnostics QoI Bug: Diagnostics Quality of Implementation type checker Area → compiler: Semantic analysis labels Nov 15, 2024
xedin added a commit to xedin/swift that referenced this issue Nov 15, 2024
If the base type of the specialization is invalid,
the AST node is going to be replaced with `ErrorExpr`.

We need to handle that gracefully when attempting
to apply specialization in such situations.

Resolves: swiftlang#77644
@xedin xedin linked a pull request Nov 15, 2024 that will close this issue
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 itself diagnostics QoI Bug: Diagnostics Quality of Implementation type checker Area → compiler: Semantic analysis
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant