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

(lib/SymbolGraphGen) incorrect parsing of concrete Self type tokens in function signatures #78343

Open
tayloraswift opened this issue Dec 21, 2024 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels

Comments

@tayloraswift
Copy link
Member

tayloraswift commented Dec 21, 2024

Description

given some input signatures like these:

public
struct Struct
{
    public
    func combined(with other:Self) -> Self
    {
        self
    }
    public
    func combined(with other:Int) -> Int
    {
        0
    }
}

lib/SymbolGraphGen will not parse the former correctly, it will instead dump something like this:

"declarationFragments":[{"kind":"keyword","spelling":"func"},{"kind":"text","spelling":" "},{"kind":"identifier","spelling":"combined"},{"kind":"text","spelling":"("},{"kind":"externalParam","spelling":"with"},{"kind":"text","spelling":" "},{"kind":"internalParam","spelling":"other"},{"kind":"text","spelling":": `Self`"},{"kind":"text","spelling":") -> "},{"kind":"typeIdentifier","spelling":"Struct","preciseIdentifier":"s:10Signatures6StructV"}]

which contains a garbage ': `Self`' token.

for some reason, the return type is correctly detected and canonicalized from Self to Struct.

this only affects non-generic Self, truly generic Self does not appear to be affected.

Reproduction

see above

Expected behavior

there should be a text token containing ': ' and a typeIdentifier token containing Struct.

Environment

$ swift --version
Swift version 6.0.2 (swift-6.0.2-RELEASE)
Target: x86_64-unknown-linux-gnu

Additional information

No response

@tayloraswift tayloraswift added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

1 participant