Repository navigation
impact: file:line inside a method body names that method, though the line assigns a field - #1814
Merged
Merged
Conversation
…line assigns a field Symptom: `impact lib.py:3` on `self.items = []` inside `Orders.__init__` answered "field Orders.items" instead of `Orders.__init__` (python/lambda-is-named-by-its-place, control "file:line inside a method body is still that method"). Cause: field_rows now resolves `file.ext:N` to a field recorded on that line, and the resolver returns that field unless a callable STARTS on the line. A Python attribute assigned in a method body is recorded as a field on the assigning line, so the enclosing method lost to it. G.decl_at_line already refused it; the const-on-the-line branch after it did not look at enclosing callables. Fix: drop the field candidate for a file:line when a callable starting above the line spans it (not a module or class body, not a lambda, not a field-initializer node, and not through a type declared inside that callable). A field line in a class body or at module level, and a const whose initializer holds a function, resolve as before. Tests: python/lambda-is-named-by-its-place 26/26 (25/26 before). tests/run.py --lang python 271/271 (270/271 before); java 304/304, typescript 181/185, javascript 242/245, the same failing checks as before the change. Co-authored-by: axiomcode-bot[bot] <334110751+axiomcode-bot[bot]@users.noreply.github.com>
swapnilpaliwal-sd
requested review from
JaredHLZhang,
Whua689 and
suyashpaliwal26
as code owners
September 30, 2026 07:09
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
python/lambda-is-named-by-its-placein the query-layer suite (tests/run.py, which CI does not run) failed one control on 0.1.9. Afile:lineinside a method body named a field recorded on that line instead of the method:A change for JavaScript consts made
file:lineresolve to a field recorded on that line unless a callable starts on it. Python recordsself.items = []as a field of the class, so the field won over the enclosing__init__.Fix. A new
Impact.in_bodydrops the field when a callable that starts above the line spans it. These do not count as enclosing callables:Module-level constants, class-body fields and the JavaScript const cases resolve as before.
Tests (rebased on the current 0.1.9)
lambda-is-named-by-its-place: 35/35 across its four languages.edit-targets-the-declaration-edited: 19/19.called-but-undeclared: 4/4.tests/run.py --lang python: 271/271, against 270/271 before this change.