Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions crates/ty_ide/src/hover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3624,6 +3624,37 @@ def function():
assert_snapshot!(test.hover(), @"Hover provided no content");
}

#[test]
fn hover_named_expression_target() {
let test = CursorTest::builder()
.source(
"mymod.py",
r#"
if a<CURSOR> := 10:
pass
"#,
)
.build();

assert_snapshot!(test.hover(), @r###"
Literal[10]
---------------------------------------------
```python
Literal[10]
```
---------------------------------------------
info[hover]: Hovered content is
--> mymod.py:2:4
|
2 | if a := 10:
| ^- Cursor offset
| |
| source
3 | pass
|
"###);
}

impl CursorTest {
fn hover(&self) -> String {
use std::fmt::Write;
Expand Down
6 changes: 3 additions & 3 deletions crates/ty_python_semantic/src/types/infer/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8164,10 +8164,10 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> {
value,
} = named;

self.infer_expression(target, TypeContext::default());

self.add_binding(named.target.as_ref().into(), definition, |builder, tcx| {
builder.infer_expression(value, tcx)
let ty = builder.infer_expression(value, tcx);
builder.store_expression_type(target, ty);
ty
})
}

Expand Down
Loading