Skip to content

Commit

Permalink
optimize._get_def_from_ast_container: Use last definition
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed Feb 3, 2025
1 parent c8c7552 commit a17580e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pymbolic/mapper/optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ def _get_def_from_ast_container(
name: str,
node_type: type[AstDefNodeT]
) -> AstDefNodeT:
for entry in container:
# Return the last definition in the container, not the first.
# This is relevant, e.g., in the case of @overload of methods.
for entry in reversed(list(container)):
if isinstance(entry, node_type) and entry.name == name:
return entry

Expand Down

0 comments on commit a17580e

Please sign in to comment.