Skip to content

Fix phantom argument attachment in Fluent DSL member expressions#2795

Draft
narangtanmay wants to merge 2 commits into
Fraunhofer-AISEC:mainfrom
narangtanmay:fix/fluent-dsl-phantom-args
Draft

Fix phantom argument attachment in Fluent DSL member expressions#2795
narangtanmay wants to merge 2 commits into
Fraunhofer-AISEC:mainfrom
narangtanmay:fix/fluent-dsl-phantom-args

Conversation

@narangtanmay

Copy link
Copy Markdown

Summary

member() with an explicit base lambda (e.g. call("doSomething") { member("field1") { ref("s1") } }) attached the base expression to the wrong ArgumentHolder. A plain lambda resolves its enclosing holder from where it's written, not where it's invoked, so ref("s1") resolved to the outer Call and added itself as a phantom second argument.

base now declares its own Holder context parameter, bound at invocation rather than capture. Calling it under a no-op DiscardHolder means any ref()/member() inside it attaches there instead of leaking into the real outer holder.

Removes the makeMagic per-callsite flag previously needed as a workaround at ref() call sites.

Test plan

  • cpg-core:test (FluentTest.testMemberWithBaseAttachesExactlyOnce)
  • cpg-analysis:test (QueryTest)
  • cpg-core:compileKotlin

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Tanmay seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@narangtanmay narangtanmay force-pushed the fix/fluent-dsl-phantom-args branch from 7452117 to 1f199c7 Compare June 18, 2026 09:15
@narangtanmay narangtanmay marked this pull request as draft June 18, 2026 09:20
@narangtanmay narangtanmay force-pushed the fix/fluent-dsl-phantom-args branch from 1f199c7 to e025dd1 Compare June 18, 2026 09:23
member() base lambdas evaluated eagerly under the enclosing Call's
ArgumentHolder, attaching ref()/member() inside them as phantom
arguments before member() itself ran. Clean up the phantom via
holder -= memberBase, mirroring the existing memberCall() fix.

Removes the makeMagic flag on ref(), now redundant.
base now declares its own Holder context parameter, resolved at
invocation rather than capture. Calling it under a no-op
DiscardHolder means ref()/member() inside it never reach the real
outer holder, removing the need for the holder -= memberBase cleanup.
@narangtanmay narangtanmay force-pushed the fix/fluent-dsl-phantom-args branch from e025dd1 to 7beddf7 Compare June 18, 2026 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants