Skip to content

Conversation

@slavapestov
Copy link
Contributor

Previously we would look for a derived source before an explicit one,
on account of the explicit one possibly being redundant. However, the
presence of 'self-derived' sources meant that we had to call
getMinimalConformanceSource() to ensure the derived sources
were actually usable and would not produce an infinite conformance
access path.

I'd like to remove getMinimalConformanceSource() now that we have
an alternate algorithm to identify redundant explicit requirements.

Instead, we can handle the explicit case first, by checking for a
conformance requirement in the generic signature -- its presence
means it was not redundant, by construction.

Then once we handle that case, we know we're going to use a derived
source, and finding the shortest one seems to be good enough.

This fixes the IRGen crash in https://bugs.swift.org/browse/SR-11153;
the requirement signatures in that test still have unnecessary
same-type requirements printed, so I added a separate RUN: line
for those, and it's marked as known-failing with 'not %FileCheck'.

…anceSource()

Previously we would look for a derived source before an explicit one,
on account of the explicit one possibly being redundant. However, the
presence of 'self-derived' sources meant that we had to call
getMinimalConformanceSource() to ensure the derived sources
were actually usable and would not produce an infinite conformance
access path.

I'd like to remove getMinimalConformanceSource() now that we have
an alternate algorithm to identify redundant explicit requirements.

Instead, we can handle the explicit case first, by checking for a
conformance requirement in the generic signature -- its presence
means it was not redundant, by construction.

Then once we handle that case, we know we're going to use a derived
source, and finding the shortest one seems to be good enough.

This fixes the IRGen crash in https://bugs.swift.org/browse/SR-11153;
the requirement signatures in that test still have unnecessary
same-type requirements printed, so I added a separate RUN: line
for those, and it's marked as known-failing with 'not %FileCheck'.
This test case was also posted by a developer in
https://bugs.swift.org/browse/SR-11153, but it appears to
be a different problem that was fixed in Swift 5.2.
@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - d59f01d

@slavapestov
Copy link
Contributor Author

@swift-ci Please test macOS

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test macOS

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - d59f01d

@slavapestov slavapestov merged commit 86fa47b into swiftlang:main Mar 12, 2021
@davezarzycki
Copy link
Contributor

davezarzycki commented Mar 12, 2021

Hi @slavapestov, this appears to have caused a regression on my Fedora 33 (x86-64) box. Any theories?

FAIL: Swift(linux-x86_64) :: Generics/sr11153.swift (1259 of 14255)
******************** TEST 'Swift(linux-x86_64) :: Generics/sr11153.swift' FAILED ********************
Script:
--
: 'RUN: at line 1';   /home/dave/b/u/t/bin/swift-frontend -target x86_64-unknown-linux-gnu  -module-cache-path /home/dave/b/u/t/swift-test-results/x86_64-unknown-linux-gnu/clang-module-cache -swift-version 4  -ignore-module-source-info  -typo-correction-limit 10  -typecheck -debug-generic-signatures /home/dave/ro_s/u/swift/test/Generics/sr11153.swift 2>&1 | not /usr/bin/python3.9 /home/dave/ro_s/u/swift/utils/PathSanitizingFileCheck --sanitize BUILD_DIR=/home/dave/b/u/t/tools/swift --sanitize SOURCE_DIR=/home/dave/ro_s/u/swift --use-filecheck /home/dave/b/u/t/bin/FileCheck  /home/dave/ro_s/u/swift/test/Generics/sr11153.swift
: 'RUN: at line 2';   /home/dave/b/u/t/bin/swift-frontend -target x86_64-unknown-linux-gnu  -module-cache-path /home/dave/b/u/t/swift-test-results/x86_64-unknown-linux-gnu/clang-module-cache -swift-version 4  -ignore-module-source-info  -typo-correction-limit 10  -emit-ir /home/dave/ro_s/u/swift/test/Generics/sr11153.swift
--
Exit Code: 134

Command Output (stderr):
--
/home/dave/ro_s/u/swift/test/Generics/sr11153.swift:4:11: error: CHECK: expected string not found in input
// CHECK: Requirement signature: <Self where Self.Field : FieldAlgebra>
          ^
<stdin>:2:1: note: scanning from here
0x7fb08a0 Module name=sr11153
^
<stdin>:11:1: note: possible intended match here
Generic signature: <Self where Self : FieldAlgebra>
^

Input file: <stdin>
Check file: /home/dave/ro_s/u/swift/test/Generics/sr11153.swift

-dump-input=help explains the following input dump.

Input was:
<<<<<<
           1:
           2: 0x7fb08a0 Module name=sr11153
check:4'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
           3:  0x7fb0c50 FileUnit file="SOURCE_DIR/test/Generics/sr11153.swift"
check:4'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           4:  0x7fb10a0 ProtocolDecl name=VectorSpace
check:4'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           5: Generic signature: <Self where Self : VectorSpace>
check:4'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           6: Canonical generic signature: <τ_0_0 where τ_0_0 : VectorSpace>
check:4'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           7:
check:4'0     ~
           8: 0x7fb08a0 Module name=sr11153
check:4'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           9:  0x7fb0c50 FileUnit file="SOURCE_DIR/test/Generics/sr11153.swift"
check:4'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          10:  0x7fb13e8 ProtocolDecl name=FieldAlgebra
check:4'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          11: Generic signature: <Self where Self : FieldAlgebra>
check:4'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:4'1     ?                                                   possible intended match
          12: Canonical generic signature: <τ_0_0 where τ_0_0 : FieldAlgebra>
check:4'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          13:
check:4'0     ~
          14: 0x7fb08a0 Module name=sr11153
check:4'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          15:  0x7fb0c50 FileUnit file="SOURCE_DIR/test/Generics/sr11153.swift"
check:4'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          16:  0x7fb9d00 ProtocolDecl name=ComparableFieldAlgebra
check:4'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           .
           .
           .
>>>>>>
/home/dave/b/u/t/tools/swift/test-linux-x86_64/Generics/Output/sr11153.swift.script: line 2: 94482 Aborted                 /home/dave/b/u/t/bin/swift-frontend -target x86_64-unknown-linux-gnu -module-cache-path /home/dave/b/u/t/swift-test-results/x86_64-unknown-linux-gnu/clang-module-cache -swift-version 4 -ignore-module-source-info -typo-correction-limit 10 -typecheck -debug-generic-signatures /home/dave/ro_s/u/swift/test/Generics/sr11153.swift 2>&1
     94484 Done                    | not /usr/bin/python3.9 /home/dave/ro_s/u/swift/utils/PathSanitizingFileCheck --sanitize BUILD_DIR=/home/dave/b/u/t/tools/swift --sanitize SOURCE_DIR=/home/dave/ro_s/u/swift --use-filecheck /home/dave/b/u/t/bin/FileCheck /home/dave/ro_s/u/swift/test/Generics/sr11153.swift

@davezarzycki
Copy link
Contributor

Whoops, the regression was actually the other pull request you merged this morning: #36411

slavapestov added a commit to slavapestov/swift that referenced this pull request Mar 12, 2021
I added this test case in swiftlang#36402;
the change in swiftlang#36411 correctly
flags some bogus same-type requirements in a minimized signature
and asserts.
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.

3 participants