mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 13:51:37 +00:00
[red-knot] detect invalid return type (#16540)
## Summary This PR closes #16248. If the return type of the function isn't assignable to the one specified, an `invalid-return-type` error occurs. I thought it would be better to report this as a different kind of error than the `invalid-assignment` error, so I defined this as a new error. ## Test Plan All type inconsistencies in the test cases have been replaced with appropriate ones. --------- Co-authored-by: Carl Meyer <carl@astral.sh>
This commit is contained in:
parent
e17cd350b6
commit
78b5f0b165
43 changed files with 983 additions and 103 deletions
|
@ -894,8 +894,12 @@ where
|
|||
let pre_return_state = matches!(last_stmt, ast::Stmt::Return(_))
|
||||
.then(|| builder.flow_snapshot());
|
||||
builder.visit_stmt(last_stmt);
|
||||
let scope_start_visibility =
|
||||
builder.current_use_def_map().scope_start_visibility;
|
||||
if let Some(pre_return_state) = pre_return_state {
|
||||
builder.flow_restore(pre_return_state);
|
||||
builder.current_use_def_map_mut().scope_start_visibility =
|
||||
scope_start_visibility;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue