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

[SR-4294] Warn about overly-nested generic type specifiers #46877

Open
jckarter opened this issue Mar 20, 2017 · 3 comments
Open

[SR-4294] Warn about overly-nested generic type specifiers #46877

jckarter opened this issue Mar 20, 2017 · 3 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers

Comments

@jckarter
Copy link
Member

Previous ID SR-4294
Radar None
Original Reporter @jckarter
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DiagnosticsQoI, StarterBug
Assignee None
Priority Medium

md5: c1aab4167ab2d03975e533b9a662698f

Issue Description:

https://twitter.com/steipete/status/843896945718546434

The tweet is in C++, but the same problem could affect Swift. A warning about overly-nested generic type specifiers that have enough piled-up closing >>>>>> brackets to be mistaken for a conflict marker in version control might be helpful, not only for tooling interaction, but for code cleanliness, since you should probably consider using a type alias at that point.

@belkadan
Copy link
Contributor

Resetting assignee for all Starter Bugs not modified since 2018.

@swift-ci
Copy link
Collaborator

swift-ci commented Dec 3, 2020

Comment by Minhyuk Kim (JIRA)

I'd like to take on this issue, but I'm not sure where to start with. @jckarter could you please give me few pointers on which files/folders to look?

@jckarter
Copy link
Member Author

jckarter commented Dec 3, 2020

A good place to start looking might be in the TypeResolver, in TypeCheckType.cpp. The compiler represents the source-level spelling of a type in a TypeRepr object, and the TypeResolver contains the code that resolves this into a reference to a specific type, raising diagnostics if there are issues such as references to nonexistent types. You could look at where we resolve GenericIdentTypeRepr (which is the subclass for the representation for a generic type reference like Foo<....>) and check whether the TypeRepr for its final argument is also a nested GenericIdentTypeRepr, repeating up to 6 or so levels of nesting, and then check the `AngleBrackets` source range of all of them to see whether the closing brackets line up in a row like >>>>>>.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants