Control flow: return and raise (#17121)

We add support for `return` and `raise` statements in the control flow
graph: we simply add an edge to the terminal block, push the statements
to the current block, and proceed.

This implementation will have to be modified somewhat once we add
support for `try` statements - then we will need to check whether to
_defer_ the jump. But for now this will do!

Also in this PR: We fix the `unreachable` diagnostic range so that it
lumps together consecutive unreachable blocks.
This commit is contained in:
Dylan 2025-04-03 08:30:29 -05:00 committed by GitHub
parent 755ece0c36
commit d401a5440e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 194 additions and 14 deletions

View file

@ -16,6 +16,7 @@ mod tests {
use test_case::test_case;
#[test_case("no_flow.py")]
#[test_case("jumps.py")]
fn control_flow_graph(filename: &str) {
let path = PathBuf::from("resources/test/fixtures/cfg").join(filename);
let source = fs::read_to_string(path).expect("failed to read file");