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

[Typechecker] Emit a specialised diagnostic for redeclaration errors when the declaration is synthesised #31915

Merged
merged 6 commits into from May 21, 2020

Conversation

theblixguy
Copy link
Collaborator

@theblixguy theblixguy commented May 20, 2020

At the moment, some redeclaration errors involving synthesised declarations can cause compiler crashes. For example:

@propertyWrapper 
struct Wrapper {
  var wrappedValue: Int
}

struct S {
  @Wrapper var foo1 = 123
  var _foo1 = 123
}

This currently crashes in the AST verifier on master and in SILGen on 5.3. Upon investigation, this seems to be a regression caused by #31037.

To fix the problem, I have added a specialised diagnostic for situations where the current declaration is synthesised. This also fixes a problem where the redeclaration diagnostics did not have a valid source location.

Resolves SR-12839
Resolves rdar://problem/63496795

@theblixguy theblixguy requested a review from CodaFi May 20, 2020 15:32
@xedin xedin requested a review from hborla May 20, 2020 17:53
include/swift/AST/DiagnosticsSema.def Outdated Show resolved Hide resolved
test/decl/var/property_wrappers.swift Outdated Show resolved Hide resolved
test/decl/var/property_wrappers.swift Show resolved Hide resolved
test/Sema/enum_conformance_synthesis.swift Outdated Show resolved Hide resolved
@theblixguy
Copy link
Collaborator Author

@swift-ci please smoke test

@theblixguy
Copy link
Collaborator Author

@swift-ci please smoke test

Copy link
Member

@hborla hborla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you @theblixguy !

@theblixguy
Copy link
Collaborator Author

@hborla Do you know if this can be cherry-picked to 5.3? I'd like to do that so we can fix the crash, alternatively we can revert #31037 on the 5.3 branch only (but that means we don't get the improved diagnostics).

@hborla
Copy link
Member

hborla commented May 21, 2020

@theblixguy yes, please prepare a PR for the 5.3 branch. Thank you!

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.

None yet

3 participants