Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Sort Properties After Creation#175

Open
LePips wants to merge 6 commits intoCreateAPI:mainCreateAPI/CreateAPI:mainfrom
LePips:sortPropertiesAlphabetically-proper-sortingLePips/CreateAPI:sortPropertiesAlphabetically-proper-sortingCopy head branch name to clipboard
Open

Sort Properties After Creation#175
LePips wants to merge 6 commits intoCreateAPI:mainCreateAPI/CreateAPI:mainfrom
LePips:sortPropertiesAlphabetically-proper-sortingLePips/CreateAPI:sortPropertiesAlphabetically-proper-sortingCopy head branch name to clipboard

Conversation

@LePips
Copy link
Contributor

@LePips LePips commented Dec 19, 2022

Sorts created properties, which go through their own independent renamings if applicable, instead of the raw keys.

@LePips
Copy link
Contributor Author

LePips commented Dec 19, 2022

Interesting, the tests' type checker couldn't do that inference, I think due to handle(error:_).

Edit:
After a minimal playground test, seems like so. I see now that the interference was removed from the function return type, but strange that it works on my machine (cleaned and everything). However, the test below doesn't work on my machine. 🤷

Edit edit:
Seems like a Swift 5.6 issue.

Minimal Example
let handleWarningAsError = false

func handle<T>(warning: String) -> T? {
    if handleWarningAsError {
        fatalError()
    } else {
        print(warning)
        return nil
    }
}

let keys = ["foo", "bar"]

struct Property {
    
    let name: String
    let uuid = UUID()
}

let properties = keys.compactMap { key in // Error: ambiguous, fix with [Property]
    
    if key == "foo" {
        return handle(warning: "You are foo, I don't like you")
    }
    
    return Property(name: key)
}

print(properties)

@LePips
Copy link
Contributor Author

LePips commented Jan 10, 2023

@liamnichols I apologize for the ping, could this and #177 receive a review as I would like to go ahead with some work that would use these features. Thank you!

Copy link
Member

@liamnichols liamnichols left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @LePips, really sorry about the delay in getting though these notifications! Thanks for taking the time to work on this, I really appreciate it!

The changes looks good to me assuming that it is doing what you say it does, but could you maybe replicate it in the tests somehow so that we can be sure not to break the behaviour in the future by mistake? 🙏

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.

useSwiftyPropertyNames and sortPropertiesAlphabetically ordering

2 participants

Comments

Close sidebar
Morty Proxy This is a proxified and sanitized view of the page, visit original site.