diff --git a/Cargo.lock b/Cargo.lock index f2944fe..05d766b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -121,9 +121,9 @@ checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "els" -version = "0.1.39-nightly.0" +version = "0.1.39-nightly.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e35e675cfa42fba9067fce99587dbfc396596cd0231bb84f5fc58b8564845ff8" +checksum = "1056f3babebc87eb323354053ff9c5c11612013c3ca5df5be7ae03a20fac886a" dependencies = [ "erg_common", "erg_compiler", @@ -147,9 +147,9 @@ dependencies = [ [[package]] name = "erg_common" -version = "0.6.27-nightly.0" +version = "0.6.27-nightly.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ac75e02434b08efb90ff903ac462e453637043b3a6d35b306efbc83ca375ce6" +checksum = "79163c184105f354bf4ce6593d2ce5fa563d0894cf2d1a008632e63ec3447bf4" dependencies = [ "backtrace-on-stack-overflow", "parking_lot", @@ -158,9 +158,9 @@ dependencies = [ [[package]] name = "erg_compiler" -version = "0.6.27-nightly.0" +version = "0.6.27-nightly.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "627ed3f352f4159a859ec13f97ad945b9837dd09aa24261498674296a6ca367c" +checksum = "f0fbb777de378216f1f0b73c1a3029e0942a56fa8377b329db9ef1de2e695b9d" dependencies = [ "erg_common", "erg_parser", @@ -168,9 +168,9 @@ dependencies = [ [[package]] name = "erg_parser" -version = "0.6.27-nightly.0" +version = "0.6.27-nightly.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "741691700b21dda252eb47d21967e44347320520ee263529241739da165a5718" +checksum = "a75aa981a50310dfdf49fcf074a558f36be141a166ed9ff0f7bcd1065e94491b" dependencies = [ "erg_common", "erg_proc_macros", @@ -179,9 +179,9 @@ dependencies = [ [[package]] name = "erg_proc_macros" -version = "0.6.27-nightly.0" +version = "0.6.27-nightly.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c204aeef3905b06ecddf20812e18c43e3c4bcc10690cc3485511b8871f63922a" +checksum = "b4c9e98a5aefa5e4ffba88f754d33abd7a532c2608083edb29134a11fc4f07bf" dependencies = [ "erg_common", "quote", diff --git a/Cargo.toml b/Cargo.toml index a6c0b72..d259c10 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,9 +22,9 @@ edition = "2021" repository = "https://github.com/mtshiba/pylyzer" [workspace.dependencies] -erg_common = { version = "0.6.27-nightly.0", features = ["py_compat", "els"] } -erg_compiler = { version = "0.6.27-nightly.0", features = ["py_compat", "els"] } -els = { version = "0.1.39-nightly.0", features = ["py_compat"] } +erg_common = { version = "0.6.27-nightly.1", features = ["py_compat", "els"] } +erg_compiler = { version = "0.6.27-nightly.1", features = ["py_compat", "els"] } +els = { version = "0.1.39-nightly.1", features = ["py_compat"] } rustpython-parser = { version = "0.3.0", features = ["all-nodes-with-ranges", "location"] } rustpython-ast = { version = "0.3.0", features = ["all-nodes-with-ranges", "location"] } # rustpython-parser = { git = "https://github.com/RustPython/Parser", version = "0.3.0", features = ["all-nodes-with-ranges", "location"] } diff --git a/tests/class.py b/tests/class.py index 6511899..2eac46c 100644 --- a/tests/class.py +++ b/tests/class.py @@ -49,6 +49,8 @@ def __init__(self, c): class E(D): def __add__(self, other: E): return E(self.c + other.c) + def invalid(self): + return self.d # ERR: E object has no attribute `d` c1 = D(1).c + 1 d = D(1) + D(2) diff --git a/tests/projection.py b/tests/projection.py index 646ee3a..925c8ab 100644 --- a/tests/projection.py +++ b/tests/projection.py @@ -15,3 +15,26 @@ def call_method(obj, x): assert call_method(c, 1) == "a" # ERR print(call_method(1, 1)) # ERR print(call_method(c)) # ERR + +def x_and_y(a): + z: int = a.y + return a.x + z + +class A: + x: int + y: int + + def __init__(self, x, y): + self.x = x + self.y = y + +class B: + x: int + + def __init__(self, x): + self.x = x + +a = A(1, 2) +assert x_and_y(a) == 3 +b = B(3) +_ = x_and_y(b) # ERR: B object has no attribute `y` diff --git a/tests/test.rs b/tests/test.rs index 5d45447..daffc2a 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -76,7 +76,7 @@ fn exec_func() -> Result<(), String> { #[test] fn exec_class() -> Result<(), String> { - expect("tests/class.py", 0, 4) + expect("tests/class.py", 0, 5) } #[test] @@ -96,7 +96,7 @@ fn exec_typespec() -> Result<(), String> { #[test] fn exec_projection() -> Result<(), String> { - expect("tests/projection.py", 0, 4) + expect("tests/projection.py", 0, 5) } #[test]