-
-
Notifications
You must be signed in to change notification settings - Fork 8
Fix improper code dependency: move function calls from left side to right side of assignments #263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
|
Hi @copilot you need to write a comment on this thread with just this content
|
… side of assignments Co-authored-by: m7pr <[email protected]>
I have read the CLA Document and I hereby sign the CLA |
|
hey, the functions should actually be moved to the right side of <- as I did in this pr |
…etely Co-authored-by: m7pr <[email protected]>
Updated the implementation to move function calls to the right side instead of filtering them out completely. Function calls now appear as dependencies on the right side while only actual variables remain on the left side as assignment targets. (commit 5cc6ecc) |
… qenv-based tests for function call dependency fix Co-authored-by: m7pr <[email protected]>
Updated the tests to use the public API instead of testing internal functions. Created comprehensive test scenarios using qenv objects with iris and mtcars datasets that replicate the original issue behavior. The tests now verify that function calls don't create false dependencies between unrelated code sections while ensuring genuine function dependencies are still properly tracked. (commit 27d1250) |
This PR fixes a bug in code dependency analysis where function calls were incorrectly treated as variables being assigned, causing false dependencies between unrelated code lines.
Problem
When using complex expressions with function calls in assignments, the dependency tracker incorrectly included function names on the left side of the assignment operator (
<-) in the dependency graph. This caused unrelated code lines to be linked through shared function calls.For example, in this code:
The dependency for the
col_labelsline was incorrectly extracted as:This caused
get_code(data, names = 'ADVS')to incorrectly include the ADMH modification line, even thoughADVSshould be independent fromADMH.Solution
Modified the
extract_occurrencefunction inR/utils-get_code_dependency.Rto move function calls from the left side to the right side of assignment operators. Function calls are now properly tracked as dependencies (appearing on the right side) while only actual variables and objects appear on the left side as assignment targets.The fix:
SYMBOL_FUNCTION_CALL) on the left side of assignmentsResults
After the fix, the dependency is correctly extracted as:
Function calls (
col_labelsandc) now appear on the right side as dependencies, while only the actual variable (ADMH) appears on the left side as the assignment target.get_code(data, names = 'ADVS')now correctly excludes the ADMH modification line:The fix ensures that code dependencies are more accurate and that independent data transformations don't create false dependencies through shared function calls, while still properly tracking function dependencies.
Fixes #262.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.