Skip to content

[ConstraintSystem] Improve initial constraints printing in the type inference algorithm debug output #59856

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 3 commits into from
Jul 6, 2022

Conversation

amritpan
Copy link
Member

@amritpan amritpan commented Jul 1, 2022

These changes reduce and reformat the initial constraints printed by the type inference algorithm's debug output. By reducing repetitive locators and better sorting the constraints, the possible constraints are easier to follow.

For example, the following disjunctions:

Inactive Constraints:
  disjunction [[locator@0x13b1cf000 [OverloadedDeclRef@/Users/amritpankaur/test.swift:53:5]]]:
>  [favored]  $T0 bound to decl Swift.(file).String extension.+ : (String.Type) -> (String, String) -> String [[locator@0x13b1cf000 [OverloadedDeclRef@/Users/amritpankaur/test.swift:53:5]]];
>             $T0 bound to decl Swift.(file).Duration extension.+ : (Duration.Type) -> (Duration, Duration) -> Duration [[locator@0x13b1cf000 [OverloadedDeclRef@/Users/amritpankaur/test.swift:53:5]]];
>             ... // additional constraints
>             $T0 bound to decl Swift.(file).UInt extension.+ : (UInt.Type) -> (UInt, UInt) -> UInt [[locator@0x13b1cf000 [OverloadedDeclRef@/Users/amritpankaur/test.swift:53:5]]];
>  [favored]  $T0 bound to decl Swift.(file).Int extension.+ : (Int.Type) -> (Int, Int) -> Int [[locator@0x13b1cf000 [OverloadedDeclRef@/Users/amritpankaur/test.swift:53:5]]];
>             $T0 bound to decl _Concurrency.(file).Instant extension.+ : (ContinuousClock.Instant.Type) -> (ContinuousClock.Instant, Duration) -> ContinuousClock.Instant [[locator@0x13b1cf000 [OverloadedDeclRef@/Users/amritpankaur/test.swift:53:5]]];
>             ... // additional constraints

will now print as:

Inactive Constraints:
  disjunction [[locator@0x13aaa7800 [OverloadedDeclRef@/Users/amritpankaur/test.swift:53:5]]]:
>  [favored]  $T0 bound to decl Swift.(file).String extension.+ : (String.Type) -> (String, String) -> String
>  [favored]  $T0 bound to decl Swift.(file).Int extension.+ : (Int.Type) -> (Int, Int) -> Int
>             $T0 bound to decl Swift.(file).Duration extension.+ : (Duration.Type) -> (Duration, Duration) -> Duration
>             ... // additional constraints

@xedin xedin self-requested a review July 1, 2022 22:58
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! I have left a couple of comments inline for you to address before we merge.

@amritpan amritpan force-pushed the improve-disjunction-printing branch 2 times, most recently from 3d4ba19 to 2f42859 Compare July 2, 2022 02:09
@amritpan amritpan changed the title Improve initial constraints printing in the type inference algorithm debug output [Constraint System] Improve initial constraints printing in the type inference algorithm debug output Jul 2, 2022
@amritpan amritpan changed the title [Constraint System] Improve initial constraints printing in the type inference algorithm debug output [ConstraintSystem] Improve initial constraints printing in the type inference algorithm debug output Jul 2, 2022
@amritpan amritpan force-pushed the improve-disjunction-printing branch from 2f42859 to ad3fcc8 Compare July 2, 2022 04:04
@amritpan amritpan requested a review from xedin July 2, 2022 04:08
@amritpan amritpan force-pushed the improve-disjunction-printing branch from ad3fcc8 to 31a02b7 Compare July 2, 2022 20:47
@amritpan amritpan requested a review from xedin July 2, 2022 20:48
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.

Great, thank you!

@xedin
Copy link
Contributor

xedin commented Jul 4, 2022

@swift-ci please test

@xedin
Copy link
Contributor

xedin commented Jul 4, 2022

@amritpan Looks like you forgot to adjust one of the tests with checks constraint system output.

@amritpan amritpan force-pushed the improve-disjunction-printing branch from 31a02b7 to e23576f Compare July 5, 2022 23:17
@amritpan amritpan requested a review from xedin July 5, 2022 23:19
@xedin
Copy link
Contributor

xedin commented Jul 5, 2022

@swift-ci please test

@xedin xedin merged commit abc2157 into swiftlang:main Jul 6, 2022
@amritpan amritpan deleted the improve-disjunction-printing branch July 8, 2022 21:00
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