ruff/crates/red_knot_python_semantic/resources/mdtest/exception
Douglas Creager 0906554357
[red-knot] Combine terminal statement support with statically known branches (#15817)
This example from @sharkdp shows how terminal statements can appear in
statically known branches:
https://github.com/astral-sh/ruff/pull/15676#issuecomment-2618809716

```py
def _(cond: bool):
    x = "a"
    if cond:
        x = "b"
        if True:
            return

    reveal_type(x)  # revealed: "a", "b"; should be "a"
```

We now use visibility constraints to track reachability, which allows us
to model this correctly. There are two related changes as a result:

- New bindings are not assumed to be visible; they inherit the current
"scope start" visibility, which effectively means that new bindings are
visible if/when the current flow is reachable

- When simplifying visibility constraints after branching control flow,
we only simplify if none of the intervening branches included a terminal
statement. That is, earlier unaffected bindings are only _actually_
unaffected if all branches make it to the merge point.
2025-02-05 17:47:49 -05:00
..
basic.md [red-knot] Combine terminal statement support with statically known branches (#15817) 2025-02-05 17:47:49 -05:00
control_flow.md [red-knot] Merge Markdown code blocks inside a single section (#15950) 2025-02-05 22:26:15 +01:00
except_star.md [red-knot] mdtest: python version requirements (#14954) 2024-12-13 10:40:38 +01:00
invalid_syntax.md Improve mdtests style (#14884) 2024-12-10 13:05:51 +00:00