Skip to content

Commit

Permalink
Fix warning in Swift 5.6 (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xTim authored Mar 16, 2022
1 parent eaeb652 commit 949270e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
25 changes: 15 additions & 10 deletions Sources/LeafKit/LeafLexer/LeafParameterTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ public enum Parameter: Equatable, CustomStringConvertible {
public enum LeafKeyword: String, Equatable {
// MARK: Public - Cases

// Eval -> Bool / Other
// -----------------------
case `in`, //
`true`, // X T
`false`, // X F
`self`, // X X
`nil`, // X F X
`yes`, // X T
`no` // X F
// Eval -> Bool / Other
// -----------------------
case `in`, //
`true`, // X T
`false`, // X F
this = "self", // X X
`nil`, // X F X
`yes`, // X T
`no` // X F

// MARK: Internal Only

Expand All @@ -64,13 +64,18 @@ public enum LeafKeyword: String, Equatable {
internal var isBooleanValued: Bool { [.true, .false, .nil, .yes, .no].contains(self) }
// Value or value-indicating returns
internal var `nil`: Bool { self == .nil }
internal var identity: Bool { self == .`self` }
internal var identity: Bool { self == .this }
internal var bool: Bool? {
guard isBooleanValued else { return nil }
return [.true, .yes].contains(self)
}
}

extension LeafKeyword {
@available(*, deprecated, message: "Use .this instead")
static var `self`: Self { this }
}

// MARK: - Operator Symbols

/// Mathematical and Logical operators
Expand Down
2 changes: 1 addition & 1 deletion Sources/LeafKit/LeafSerialize/ParameterResolver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ internal struct ParameterResolver {
return data[keyPath: v] ?? .trueNil
case .keyword(let k):
switch k {
case .self: return .init(.dictionary(data))
case .this: return .init(.dictionary(data))
case .nil: return .trueNil
case .true, .yes: return .init(.bool(true))
case .false, .no: return .init(.bool(false))
Expand Down

0 comments on commit 949270e

Please sign in to comment.