-
Notifications
You must be signed in to change notification settings - Fork 225
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
Feat: Add support for Swift 4.0 #258
Conversation
e5fabbb
to
66a9bc5
Compare
@@ -1,4 +1,4 @@ | |||
// swift-tools-version:4.1 | |||
// swift-tools-version:4.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it still work when built with swift 4.1?...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will still work. The swift-tools-version specifies the minimum version of Swift required for the project but higher versions are allowed.
Sources/Errors.swift
Outdated
lhs.token == rhs.token && | ||
lhs.stackTrace == rhs.stackTrace && | ||
lhs.templateName == rhs.templateName && | ||
lhs.allTokens == rhs.allTokens |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
allTokens
check is not needed as it is computed property. Also, lines starting with 43 should be indented on one position.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also wrap this whole ==
operator in a #if swift
check.
Sources/IfTag.swift
Outdated
@@ -118,7 +118,12 @@ final class IfExpressionParser { | |||
private init(components: ArraySlice<String>, tokenParser: TokenParser, token: Token) throws { | |||
var parsedComponents = Set<Int>() | |||
var bracketsBalance = 0 | |||
self.tokens = try zip(components.indices, components).compactMap { (index, component) in | |||
#if swift(>=4.1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe it would be better to add an extension that defines compactMap
on collections for swift 4.1 rather than checking it in place? will be also easier to remove later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution! Few small comments but otherwise looks good to me.
Sources/Variable.swift
Outdated
@@ -116,9 +116,32 @@ public struct Variable : Equatable, Resolvable { | |||
|
|||
return normalize(current) | |||
} | |||
|
|||
public static func ==(lhs: Variable, rhs: Variable) -> Bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, wrap in #if swift
.
I agree that we should define The |
Hey |
Sources/_SwiftSupport.swift
Outdated
@@ -0,0 +1,42 @@ | |||
import Foundation | |||
|
|||
#if swift(>=4.1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I misread that at first and thought you made a typo, until I saw the else
clause.
Maybe make this #if !swift(>=4.1)
?
Note for those wondering: the file should be named |
@djbe Could this be tagged so that SwiftPM can pick up this fix? |
I am part of the Kitura team and we would like to update to the latest version of Stencil, however since we support Swift 4.0 and so are unable to use the latest version unless Stencil also supports Swift 4.0.
This pull requests adds support for Swift 4.0 by
Swift 4.0.3 builds have also been added to travis to check for future Swift 4.0 is supported in future builds.
These changes allow Stencil to compile and run on Swift 4.0 while still compiling with no build warnings for Swift 4.1