swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.53k stars 10.35k forks source link

compiler crash: checked decl cannot have error type #61027

Open tayloraswift opened 2 years ago

tayloraswift commented 2 years ago

Describe the bug

the following test program crashes the compiler:

func test()
{
    let x:[Int] = []
    let y:[Int] = []
    let z:[Int] = []
    for (x, (y, (z, w))) in zip(x, zip(y, z))
    {
    }
}
error: compile command failed due to signal 6 (use -v to see invocation)
checked decl cannot have error type
(var_decl range=[test3.swift:6:10 - line:6:10] "x" type='<<error type>>' interface type='<<error type>>' let readImpl=stored immutable)
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.
Stack dump:
0.      Program arguments: /home/ec2-user/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2022-09-06-a/usr/bin/swift-frontend -frontend -c -primary-file test3.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -color-diagnostics -new-driver-path /home/ec2-user/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2022-09-06-a/usr/bin/swift-driver -empty-abi-descriptor -resource-dir /home/ec2-user/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2022-09-06-a/usr/lib/swift -module-name test3 -o /tmp/TemporaryDirectory.YIyLiZ/test3-1.o
1.      Swift version 5.8-dev (LLVM a049441a0549936, Swift a973fe5375d3851)
2.      Compiling with the current language version
3.      While walking into decl 'test()' (at test3.swift:1:1)
4.      While walking into body of 'test()' (at test3.swift:1:1)
5.      While verifying VarDecl 'x' (at test3.swift:6:10)
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
/home/ec2-user/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2022-09-06-a/usr/bin/swift-frontend[0x67cbe23]
/home/ec2-user/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2022-09-06-a/usr/bin/swift-frontend[0x67c9afe]
/home/ec2-user/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2022-09-06-a/usr/bin/swift-frontend[0x67cc1af]
/lib64/libpthread.so.0(+0x118e0)[0x7fa44d2918e0]
/lib64/libc.so.6(gsignal+0x110)[0x7fa44b5b4ca0]
/lib64/libc.so.6(abort+0x148)[0x7fa44b5b6148]
/home/ec2-user/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2022-09-06-a/usr/bin/swift-frontend[0x1c8433e]
/home/ec2-user/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2022-09-06-a/usr/bin/swift-frontend[0x1c8460b]
/home/ec2-user/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2022-09-06-a/usr/bin/swift-frontend[0x1c7caac]
/home/ec2-user/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2022-09-06-a/usr/bin/swift-frontend[0x1c860b7]
/home/ec2-user/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2022-09-06-a/usr/bin/swift-frontend[0x1c89961]
/home/ec2-user/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2022-09-06-a/usr/bin/swift-frontend[0x1c89a57]
/home/ec2-user/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2022-09-06-a/usr/bin/swift-frontend[0x1c891b8]
/home/ec2-user/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2022-09-06-a/usr/bin/swift-frontend[0x1c88853]
/home/ec2-user/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2022-09-06-a/usr/bin/swift-frontend[0x1c8b6e6]
/home/ec2-user/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2022-09-06-a/usr/bin/swift-frontend[0x1c8608e]
/home/ec2-user/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2022-09-06-a/usr/bin/swift-frontend[0x1c86023]
/home/ec2-user/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2022-09-06-a/usr/bin/swift-frontend[0x1e35a18]
/home/ec2-user/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2022-09-06-a/usr/bin/swift-frontend[0x1c733a8]
/home/ec2-user/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2022-09-06-a/usr/bin/swift-frontend[0x1f2f0b7]
/home/ec2-user/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2022-09-06-a/usr/bin/swift-frontend[0x17165fd]
/home/ec2-user/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2022-09-06-a/usr/bin/swift-frontend[0x1714168]
/home/ec2-user/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2022-09-06-a/usr/bin/swift-frontend[0x1714144]
/home/ec2-user/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2022-09-06-a/usr/bin/swift-frontend[0x6ea7a9]
/home/ec2-user/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2022-09-06-a/usr/bin/swift-frontend[0x6df0ea]
/home/ec2-user/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2022-09-06-a/usr/bin/swift-frontend[0x6df087]
/home/ec2-user/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2022-09-06-a/usr/bin/swift-frontend[0x68eec9]
/home/ec2-user/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2022-09-06-a/usr/bin/swift-frontend[0x4c1f4c]
/lib64/libc.so.6(__libc_start_main+0xea)[0x7fa44b5a213a]
/home/ec2-user/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2022-09-06-a/usr/bin/swift-frontend[0x4c111a]

i reproduced the crash on DEVELOPMENT-SNAPSHOT-2022-08-18-a and DEVELOPMENT-SNAPSHOT-2022-09-06-a.

xedin commented 2 years ago

Went from a fallback diagnostic (type of expression is ambiguous without more context) to a crash :/

theblixguy commented 2 years ago

It seems like we're creating AllowTupleTypeMismatch and IgnoreUnresolvedPatternVar fixes, but it doesn't end up in the Fixes array for the solution so applySolution does not call applySolutionFixes which means we do not emit the associated diagnostics.

robwahl commented 2 years ago

Hi, I have time to chase this down. Please assign bug to me

robwahl commented 2 years ago

On it