swiftlang / swift

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

(6.1) regression in checking tuple initialization state #75492

Open tayloraswift opened 1 month ago

tayloraswift commented 1 month ago

Description

this used to (does?) compile up through 6.0, but (has) stopped compiling on main

cc @JaapWijnen , who first noticed the issue in the swift-png repo

Reproduction

func f()
{
    let t:(x:Int, y:Int)

    t.x = 0

    print(t.x)
}
error: constant 't.y' used before being initialized
1 | func f()
2 | {
3 |     let t:(x:Int, y:Int)
  |         `- note: constant defined here
4 | 
5 |     t.x = 0
6 | 
7 |     print(t.x)
  |           `- error: constant 't.y' used before being initialized
8 | }
9 | 

Expected behavior

it should compile

Environment

$ /swift/swift-DEVELOPMENT-SNAPSHOT-2024-07-24-a-amazonlinux2/usr/bin/swift --version Swift version 6.0-dev (LLVM 3c6e1d334961f5e, Swift 384d7f77a53d8a0) Target: x86_64-unknown-linux-gnu

Additional information

No response

ktoso commented 1 month ago

Thanks for reporting!

rdar://132531934

xedin commented 1 month ago

@ktoso I think this is SILGen, not type-checker issue