Skip to content

[ConstraintSystem] Finish porting unresolved member reference failures. #29000

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

Merged
merged 1 commit into from
Jan 5, 2020

Conversation

hborla
Copy link
Member

@hborla hborla commented Jan 3, 2020

This covers member failures where the error is at the declaration, so the result of member lookup is "already diagnosed".

We record references to erroneous member declarations as a hole in order to allow the constraint solver to continue, and to suppress diagnostics at the site of the reference (since the error is already diagnosed at the declaration).

Note: We need to record and diagnose at least one fix in order to solve the constraint system in the new diagnostic infrastructure. For this reason, we record the DefineMemberBasedOnUse fix for erroneous members, but flag the fix as "already diagnosed" to suppress the error message.

@hborla hborla requested a review from xedin January 3, 2020 23:50
@hborla
Copy link
Member Author

hborla commented Jan 3, 2020

@swift-ci please smoke test

@@ -251,7 +251,8 @@ struct Toe {
let toenail: Nail // expected-error {{use of undeclared type 'Nail'}}

func clip() {
toenail.inspect { x in
// FIXME: We shouldn't report this because toenail.inspect is a hole
toenail.inspect { x in // expected-error {{unable to infer closure return type; add explicit type to disambiguate}}
Copy link
Member Author

Choose a reason for hiding this comment

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

We can fix this by using applicable function constraint to bind hole types to the correct shape

Copy link
Contributor

@xedin xedin 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!

@@ -805,11 +805,12 @@ class UseSubscriptOperator final : public ConstraintFix {
class DefineMemberBasedOnUse final : public ConstraintFix {
Type BaseType;
DeclNameRef Name;
bool AlreadyDiagnosed;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Would you mind adding a comment about why this is necessary for posterity?

This covers member failures where the error is at the declaration, so
the result of member lookup is "already diagnosed".
@hborla hborla force-pushed the unresolved-member-expr-diagnostics branch from a3af84c to 94bbb8f Compare January 5, 2020 19:33
@hborla
Copy link
Member Author

hborla commented Jan 5, 2020

@swift-ci please smoke test

@hborla hborla merged commit 52a736e into swiftlang:master Jan 5, 2020
@hborla hborla deleted the unresolved-member-expr-diagnostics branch January 5, 2020 21:17
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.

2 participants