nicklockwood / Expression

A cross-platform Swift library for evaluating mathematical expressions at runtime
MIT License
824 stars 50 forks source link

Build failure on Swift 5.1 - partial application of 'mutating' method is not allowed #23

Closed foscomputerservices closed 5 years ago

foscomputerservices commented 5 years ago

When attempting to build the library using Swift 5.1 the following error is generated.

/.../Sources/AnyExpression.swift:1096:72: error: partial application of 'mutating' method is not allowed
        return (AnyExpression.arrayCast(value) as [Element]?).map(self.init)

Steps to repeat:

  1. Install Swift 5.1 (or Xcode 11)
  2. git clone https://github.com/nicklockwood/Expression.git
  3. cd Expression
  4. swift build

The offending code is as follows:

extension ArraySlice: _SwiftArray {
    fileprivate var values: [Any] {
        return Array(self)
    }

    static func cast(_ value: Any) -> Any? {
        return (AnyExpression.arrayCast(value) as [Element]?).map(self.init) // <-- self.init fails to compile Swift 5.1
    }
}
nicklockwood commented 5 years ago

Thanks for reporting. Fixed in 0.13.1.

foscomputerservices commented 5 years ago

Wow, thanks for the quick turn around!

Sadly, I still receive the same error. I completely deleted the Expression directory and re-followed my repeat steps above.

In looking at the file diffs here on GitHub, I'm not seeing any actual code changes to any of the files, only meta-data and comment changes.

Maybe I'm missing something?

nicklockwood commented 5 years ago

@foscomputerservices ha ha, whoops. Looks like I pushed the wrong branch 🤦‍♂️. It should be fixed now - if you're using Cocoapods you may need to pod cache clean before pulling again.

foscomputerservices commented 5 years ago

@nicklockwood, yes, that fixed it. Thanks!!!