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-3891] Imported API should always have a trailing space character on operator functions after the operator #46476

Closed
DevAndArtist mannequin opened this issue Feb 7, 2017 · 5 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. good first issue Good for newcomers

Comments

@DevAndArtist
Copy link
Mannequin

DevAndArtist mannequin commented Feb 7, 2017

Previous ID SR-3891
Radar None
Original Reporter @DevAndArtist
Type Bug
Status Resolved
Resolution Done
Environment

Xcode 8.2.1 (8C1002)

Additional Detail from JIRA
Votes 1
Component/s Source Tooling
Labels Bug, StarterBug
Assignee @marcelofabri
Priority Medium

md5: 04f6509c12af7a6703ccdb00a2258fbc

Issue Description:

The idea is simple and not critical at all. Consider this issue as a starter bug.

Currently imported operator functions have no trailing space character after the operator, like one would assume for an ordinary function name `func foo()`.

public func ><T : Comparable>(lhs: T, rhs: T) -> Bool
public func <=<T : Comparable>(lhs: T, rhs: T) -> Bool
public func ==<A : Equatable, B : Equatable>(lhs: (A, B), rhs: (A, B)) -> Bool
public static func ==(lhs: Self, rhs: Self) -> Bool

This should be changed in favor of readability and programming ligatures fonts like FiraCode.

public func > <T : Comparable>(lhs: T, rhs: T) -> Bool
public func <= <T : Comparable>(lhs: T, rhs: T) -> Bool
public func == <A : Equatable, B : Equatable>(lhs: (A, B), rhs: (A, B)) -> Bool
public static func == (lhs: Self, rhs: Self) -> Bool

Ligature fonts could then render operators from above correctly as `>`, `<=`, `==` instead of `><`, `<=<` or `==<`.

@belkadan
Copy link
Contributor

belkadan commented Feb 8, 2017

This is essentially a change to the AST printer, in lib/AST/ASTPrinter.cpp. A quick look shows that PrintAST::visitFuncDecl is probably the function to modify. Someone taking this can then run and update existing tests to match the new output.

@swift-ci
Copy link
Collaborator

Comment by Mohit Athwani (JIRA)

@belkadan I am an absolute beginner trying to contribute to an open source project for the first time ever! I looked at the visitFuncDecl function and couldn't really find much in there. Any chances you could share some more information on how to approach fixing this bug?
Thanks!

@Cbieniak
Copy link
Contributor

mohit.athwani (JIRA User) Hey mate, also new to this but ive been having a small look into this.

I think the keys to solution lie around https://github.com/apple/swift/blob/master/lib/AST/ASTPrinter.cpp#L2668
and taking advantage of this method https://github.com/apple/swift/blob/master/include/swift/AST/Identifier.h#L75

@swift-ci
Copy link
Collaborator

Comment by Mohit Athwani (JIRA)

cabie (JIRA User) Thank you so much for your help![]( The code is making like 10% more sense than it was the last time I looked at it) Could you please hide me on how I can go about debugging this issue? Could I use gdb or lldb? And how and where could I check if my code is correct? I really appreciate you taking the time out to help me out...

@marcelofabri
Copy link
Contributor

#11835

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
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. good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants