| 78 | return scopes[scope.id] |
| 79 | |
| 80 | def is_shadowed(call, name: str) -> bool: |
| 81 | node = call |
| 82 | nearest = True |
| 83 | while (parent := node.parent) is not None: |
| 84 | if parent.type in ("function_definition", "class_definition"): |
| 85 | body = parent.child_by_field_name("body") |
| 86 | if node == body: |
| 87 | is_function = parent.type == "function_definition" |
| 88 | if is_function or nearest: |
| 89 | params, rebound = facts(parent, body) |
| 90 | if name in rebound: |
| 91 | return False |
| 92 | if is_function and name in params: |
| 93 | return True |
| 94 | nearest = False |
| 95 | node = parent |
| 96 | return False |
| 97 | |
| 98 | return is_shadowed |