Skip to content

Commit ef36acf

Browse files
committed
1 parent 1178d72 commit ef36acf

File tree

4 files changed

+31
-9
lines changed

4 files changed

+31
-9
lines changed

swift-mode-font-lock.el

+1-1
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ Return nil otherwise."
535535

536536
(defconst swift-mode:expression-keywords
537537
'("as" "catch" "dynamicType" "is" "rethrows" "super" "self" "Self" "throws"
538-
"throw" "try" "async" "await" "consume" "copy" "discard")
538+
"throw" "try" "async" "await" "consume" "copy" "discard" "each")
539539
"Keywords used in expressions and types.
540540
541541
Excludes true, false, and keywords begin with a number sign.")

swift-mode-lexer.el

+8-8
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ END is the point after the token."
9999

100100
;; Token types is one of the following symbols:
101101
;;
102-
;; - prefix-operator (including try, try?, try!, await, consume, copy, and
103-
;; discard)
102+
;; - prefix-operator (including try, try?, try!, await, consume, copy, discard,
103+
;; and each)
104104
;; - postfix-operator
105105
;; - binary-operator (including as, as?, as!, is, =, ., and ->)
106106
;; - attribute (e.g. @objc, @abc(def))
@@ -611,7 +611,7 @@ return non-nil."
611611
;; statements.
612612
(member (swift-mode:token:text previous-token)
613613
'("any" "some" "inout" "borrowing" "consuming" "in" "where"
614-
"isolated"))
614+
"isolated" "each"))
615615
(member (swift-mode:token:text next-token)
616616
'("any" "some" "inout" "borrowing" "consuming" "throws"
617617
"rethrows" "in" "where" "isolated")))
@@ -990,7 +990,7 @@ Other properties are the same as the TOKEN."
990990
(cond
991991
(is-declaration 'identifier)
992992
((member text '("try" "try?" "try!" "await" "consume" "copy"
993-
"discard"))
993+
"discard" "each"))
994994
'prefix-operator)
995995
((equal text ".") 'binary-operator)
996996
((and has-preceding-space has-following-space) 'binary-operator)
@@ -1149,7 +1149,7 @@ This function does not return `implicit-;' or `type-:'."
11491149
pos-after-comment
11501150
(point))))
11511151

1152-
;; Operator (other than as, try, is, await, consume, copy, or discard)
1152+
;; Operator (other than as, try, is, await, consume, copy, discard, or each)
11531153
;;
11541154
;; Operators starts with a dot can contains dots. Other operators cannot
11551155
;; contain dots.
@@ -1248,7 +1248,7 @@ This function does not return `implicit-;' or `type-:'."
12481248
text
12491249
(- (point) (length text))
12501250
(point)))
1251-
((member text '("await" "consume" "copy" "discard"))
1251+
((member text '("await" "consume" "copy" "discard" "each"))
12521252
(swift-mode:token 'prefix-operator
12531253
text
12541254
(- (point) (length text))
@@ -1421,7 +1421,7 @@ This function does not return `implicit-;' or `type-:'."
14211421
(point)
14221422
pos-before-comment)))
14231423

1424-
;; Operator (other than as, try, is, await, consume, copy, or discard)
1424+
;; Operator (other than as, try, is, await, consume, copy, discard, or each)
14251425
;;
14261426
;; Operators which starts with a dot can contain other dots. Other
14271427
;; operators cannot contain dots.
@@ -1503,7 +1503,7 @@ This function does not return `implicit-;' or `type-:'."
15031503
text
15041504
(point)
15051505
(+ (point) (length text))))
1506-
((member text '("try" "await" "consume" "copy" "discard"))
1506+
((member text '("try" "await" "consume" "copy" "discard" "each"))
15071507
(swift-mode:token 'prefix-operator
15081508
text
15091509
(point)

test/swift-files/indent/declarations.swift

+19
Original file line numberDiff line numberDiff line change
@@ -851,3 +851,22 @@ func foo()
851851
Foo {
852852
return Bar()
853853
}
854+
855+
856+
// Value and Type Parameter Packs
857+
// https://github.com/apple/swift-evolution/blob/main/proposals/0393-parameter-packs.md#introduction
858+
// https://github.com/apple/swift-evolution/blob/main/proposals/0398-variadic-types.md
859+
860+
func constrain<each S: Sequence>(
861+
_: repeat
862+
each // swift-mode:test:known-bug
863+
S // swift-mode:test:known-bug
864+
) where (
865+
repeat
866+
( // swift-mode:test:known-bug
867+
each
868+
S
869+
)
870+
.Element
871+
) == (Int, String) {
872+
}

test/swift-files/indent/identifiers.swift

+3
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ func foo() {
230230
foo(
231231
discard: 1
232232
)
233+
foo(
234+
each: 1
235+
)
233236

234237
// Keywords reserved in particular contexts
235238
foo(

0 commit comments

Comments
 (0)