Skip to content
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

Swift: Possible improvement to ApplyExpr.toString #9749

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

geoffw0
Copy link
Contributor

@geoffw0 geoffw0 commented Jun 29, 2022

Possible improvement to ApplyExpr.toString.

The first three commits were originally part of #9737 (but have since been removed from there), where @MathiasVP said:

I like the output a lot more now, but I'm not sure we're getting the improved output for the right reasons. It looks like we're now generating "call to f()" when we can resolve the call to a static call target f, but we print just "f()" when we cannot resolve it to a target.

The reason the output looks a lot better now is that the cases where there isn't a static call target are all examples where getFunction returns a strange DotSyntaxCallExpr (or SelfApplyExpr, or ConstructorRefCallExpr) which all have strings that look like "call to f()" (because they fall into the category of calls where we can resolve the target).

For example, I think the call to bar() in the example below will get a confusing toString (since it'll just be the string "bar" and not "call to bar" even though it's a call to bar and not a reference to the variable).

func foo(_ bar: () -> ()) {
  bar()
}

foo({ print("I am a lambda :wave:") })

As a fourth commit I've added the above as a test and it works (or rather doesn't) as anticipated. The obvious fix would be to make a special case for DotSyntaxCallExpr vs everything else, but that might just be a rabbit hole of special cases - ideally I would like to find a cleaner answer.

@geoffw0 geoffw0 added no-change-note-required Swift labels Jun 29, 2022
@geoffw0
Copy link
Contributor Author

@geoffw0 geoffw0 commented Jun 29, 2022

Waiting on internal issue (github/codeql-c-team#1019).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-change-note-required Swift
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant