mirror of
https://github.com/github/codeql.git
synced 2026-07-26 21:44:02 +02:00
For a plain assignment `x = v`, the K2/FIR frontend records the set operation's end offset past the assigned value, so the left-hand-side `VarAccess` was located over the whole `x = v` rather than just the target identifier `x`. K1's set-value end offset already stops at the identifier, so the two frontends diverged (and this cascaded into the controlflow tests). A `VarAccess` should be located at the variable reference, not the whole assignment, so K1's identifier-only span is canonical. `getPlainSetValueLhsIdentifierLocation` narrows the LHS location to the target identifier for a plain `IrSetValue`, deriving the identifier end as `startOffset + name.length`. This is applied only when the target name is an unquoted simple identifier (not special, not a hard keyword, no backtick-requiring characters), so backtick-quoted names, keyword names and qualified receivers all fall back to the raw location. Gated on K2, since under K1 the raw location is already identifier-only. Relearned both suites (3333 tests each); only K2 expected files change, all narrowing LHS `VarAccess` locations to match K1. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 86bfc022-3ecc-4746-ba23-3b76c4e4c3e4