diff --git a/Cargo.lock b/Cargo.lock index df05a29f95..c056606c29 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3540,8 +3540,8 @@ checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "salsa" -version = "0.23.0" -source = "git+https://github.com/salsa-rs/salsa.git?rev=29ab321b45d00daa4315fa2a06f7207759a8c87e#29ab321b45d00daa4315fa2a06f7207759a8c87e" +version = "0.24.0" +source = "git+https://github.com/salsa-rs/salsa.git?rev=ef9f9329be6923acd050c8dddd172e3bc93e8051#ef9f9329be6923acd050c8dddd172e3bc93e8051" dependencies = [ "boxcar", "compact_str", @@ -3564,13 +3564,13 @@ dependencies = [ [[package]] name = "salsa-macro-rules" -version = "0.23.0" -source = "git+https://github.com/salsa-rs/salsa.git?rev=29ab321b45d00daa4315fa2a06f7207759a8c87e#29ab321b45d00daa4315fa2a06f7207759a8c87e" +version = "0.24.0" +source = "git+https://github.com/salsa-rs/salsa.git?rev=ef9f9329be6923acd050c8dddd172e3bc93e8051#ef9f9329be6923acd050c8dddd172e3bc93e8051" [[package]] name = "salsa-macros" -version = "0.23.0" -source = "git+https://github.com/salsa-rs/salsa.git?rev=29ab321b45d00daa4315fa2a06f7207759a8c87e#29ab321b45d00daa4315fa2a06f7207759a8c87e" +version = "0.24.0" +source = "git+https://github.com/salsa-rs/salsa.git?rev=ef9f9329be6923acd050c8dddd172e3bc93e8051#ef9f9329be6923acd050c8dddd172e3bc93e8051" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 40afa8c5a5..ad61751a7d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -146,7 +146,7 @@ regex-automata = { version = "0.4.9" } rustc-hash = { version = "2.0.0" } rustc-stable-hash = { version = "0.1.2" } # When updating salsa, make sure to also update the revision in `fuzz/Cargo.toml` -salsa = { git = "https://github.com/salsa-rs/salsa.git", rev = "29ab321b45d00daa4315fa2a06f7207759a8c87e", default-features = false, features = [ +salsa = { git = "https://github.com/salsa-rs/salsa.git", rev = "ef9f9329be6923acd050c8dddd172e3bc93e8051", default-features = false, features = [ "compact_str", "macros", "salsa_unstable", diff --git a/crates/ty_python_semantic/resources/mdtest/attributes.md b/crates/ty_python_semantic/resources/mdtest/attributes.md index 8ae31e9265..496f796c7a 100644 --- a/crates/ty_python_semantic/resources/mdtest/attributes.md +++ b/crates/ty_python_semantic/resources/mdtest/attributes.md @@ -2363,6 +2363,55 @@ reveal_type(B().x) # revealed: Unknown | Literal[1] reveal_type(A().x) # revealed: Unknown | Literal[1] ``` +And cycles between many attributes: + +```py +class ManyCycles: + def __init__(self: "ManyCycles"): + self.x1 = 0 + self.x2 = 0 + self.x3 = 0 + self.x4 = 0 + self.x5 = 0 + self.x6 = 0 + self.x7 = 1 + + def f1(self: "ManyCycles"): + self.x1 = self.x2 + self.x3 + self.x4 + self.x5 + self.x6 + self.x7 + self.x2 = self.x1 + self.x3 + self.x4 + self.x5 + self.x6 + self.x7 + self.x3 = self.x1 + self.x2 + self.x4 + self.x5 + self.x6 + self.x7 + self.x4 = self.x1 + self.x2 + self.x3 + self.x5 + self.x6 + self.x7 + self.x5 = self.x1 + self.x2 + self.x3 + self.x4 + self.x6 + self.x7 + self.x6 = self.x1 + self.x2 + self.x3 + self.x4 + self.x5 + self.x7 + self.x7 = self.x1 + self.x2 + self.x3 + self.x4 + self.x5 + self.x6 + + def f2(self: "ManyCycles"): + self.x1 = self.x2 + self.x3 + self.x4 + self.x5 + self.x6 + self.x7 + self.x2 = self.x1 + self.x3 + self.x4 + self.x5 + self.x6 + self.x7 + self.x3 = self.x1 + self.x2 + self.x4 + self.x5 + self.x6 + self.x7 + self.x4 = self.x1 + self.x2 + self.x3 + self.x5 + self.x6 + self.x7 + self.x5 = self.x1 + self.x2 + self.x3 + self.x4 + self.x6 + self.x7 + self.x6 = self.x1 + self.x2 + self.x3 + self.x4 + self.x5 + self.x7 + self.x7 = self.x1 + self.x2 + self.x3 + self.x4 + self.x5 + self.x6 + + def f3(self: "ManyCycles"): + self.x1 = self.x2 + self.x3 + self.x4 + self.x5 + self.x6 + self.x7 + self.x2 = self.x1 + self.x3 + self.x4 + self.x5 + self.x6 + self.x7 + self.x3 = self.x1 + self.x2 + self.x4 + self.x5 + self.x6 + self.x7 + self.x4 = self.x1 + self.x2 + self.x3 + self.x5 + self.x6 + self.x7 + self.x5 = self.x1 + self.x2 + self.x3 + self.x4 + self.x6 + self.x7 + self.x6 = self.x1 + self.x2 + self.x3 + self.x4 + self.x5 + self.x7 + self.x7 = self.x1 + self.x2 + self.x3 + self.x4 + self.x5 + self.x6 + + reveal_type(self.x1) # revealed: Unknown | int + reveal_type(self.x2) # revealed: Unknown | int + reveal_type(self.x3) # revealed: Unknown | int + reveal_type(self.x4) # revealed: Unknown | int + reveal_type(self.x5) # revealed: Unknown | int + reveal_type(self.x6) # revealed: Unknown | int + reveal_type(self.x7) # revealed: Unknown | int +``` + This case additionally tests our union/intersection simplification logic: ```py diff --git a/crates/ty_python_semantic/resources/primer/bad.txt b/crates/ty_python_semantic/resources/primer/bad.txt index bfff92bd22..1a4f3eed3e 100644 --- a/crates/ty_python_semantic/resources/primer/bad.txt +++ b/crates/ty_python_semantic/resources/primer/bad.txt @@ -1,2 +1,2 @@ -spark # too many iterations (in `exported_names` query) -steam.py # hangs (single threaded) +spark # too many iterations (in `exported_names` query), `should not be able to access instance member `spark` of type variable IndexOpsLike@astype in inferable position` +steam.py # dependency graph cycle when querying TypeVarInstance < 'db >::lazy_default_(Id(2e007)), set cycle_fn/cycle_initial to fixpoint iterate. diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index ec34fdd71e..016c7ea6b3 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -30,7 +30,7 @@ ty_python_semantic = { path = "../crates/ty_python_semantic" } ty_vendored = { path = "../crates/ty_vendored" } libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer", default-features = false } -salsa = { git = "https://github.com/salsa-rs/salsa.git", rev = "29ab321b45d00daa4315fa2a06f7207759a8c87e", default-features = false, features = [ +salsa = { git = "https://github.com/salsa-rs/salsa.git", rev = "ef9f9329be6923acd050c8dddd172e3bc93e8051", default-features = false, features = [ "compact_str", "macros", "salsa_unstable",