Skip to content

Commit

Permalink
Test explicit shadowing involving defs (#15174)
Browse files Browse the repository at this point in the history
Co-authored-by: Carl Meyer <[email protected]>
  • Loading branch information
hauntsaninja and carljm authored Dec 29, 2024
1 parent 7ea3a54 commit bc3a735
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,29 @@ def f(): ...

f: int = 1
```

## Explicit shadowing involving `def` statements

Since a `def` statement is a declaration, one `def` can shadow another `def`, or shadow a previous
non-`def` declaration, without error.

```py
f = 1
reveal_type(f) # revealed: Literal[1]

def f(): ...

reveal_type(f) # revealed: Literal[f]

def f(x: int) -> int:
raise NotImplementedError

reveal_type(f) # revealed: Literal[f]

f: int = 1
reveal_type(f) # revealed: Literal[1]

def f(): ...

reveal_type(f) # revealed: Literal[f]
```

0 comments on commit bc3a735

Please sign in to comment.