2626
2727// operators (should be rejected)
2828@section ( " mysection " ) let invalidOperator1 = 1 + 1
29- // expected-error@-1{{unsupported operator in a '@const' expression}}
29+ // expected-error@-1{{unsupported operator in a constant expression}}
3030@section ( " mysection " ) let invalidOperator2 = 3.14 * 2.0
31- // expected-error@-1{{unsupported operator in a '@const' expression}}
31+ // expected-error@-1{{unsupported operator in a constant expression}}
3232@section ( " mysection " ) let invalidOperator3 : Int = - ( 1 )
33- // expected-error@-1{{unsupported operator in a '@const' expression}}
33+ // expected-error@-1{{unsupported operator in a constant expression}}
3434
3535// non-literal expressions (should be rejected)
3636@section ( " mysection " ) let invalidNonLiteral1 = Int . max
37- // expected-error@-1{{not supported in a '@const' expression}}
37+ // expected-error@-1{{not supported in a constant expression}}
3838@section ( " mysection " ) let invalidNonLiteral2 = UInt8 ( 42 )
39- // expected-error@-1{{not supported in a '@const' expression}}
39+ // expected-error@-1{{not supported in a constant expression}}
4040@section ( " mysection " ) let invalidNonLiteral3 = true . hashValue
41- // expected-error@-1{{not supported in a '@const' expression}}
41+ // expected-error@-1{{not supported in a constant expression}}
4242
4343func foo( ) -> Int { return 42 }
4444func bar( x: Int ) -> String { return " test " }
@@ -49,21 +49,21 @@ func bar(x: Int) -> String { return "test" }
4949
5050// invalid function references (should be rejected)
5151@section ( " mysection " ) let invalidFuncRef1 = foo ( )
52- // expected-error@-1{{not supported in a '@const' expression}}
52+ // expected-error@-1{{not supported in a constant expression}}
5353@section ( " mysection " ) let invalidFuncRef2 = Bool . self. random
54- // expected-error@-1{{closures not supported in a '@const' expression}}
54+ // expected-error@-1{{closures not supported in a constant expression}}
5555@section ( " mysection " ) let invalidFuncRef3 = ( Bool . self as Bool . Type) . random
56- // expected-error@-1{{not supported in a '@const' expression}}
56+ // expected-error@-1{{not supported in a constant expression}}
5757
5858// generic function references (should be rejected)
5959@section ( " mysection " ) let invalidGenericFunc = [ Int ] . randomElement
60- // expected-error@-1{{not supported in a '@const' expression}}
60+ // expected-error@-1{{not supported in a constant expression}}
6161
6262// closures (should be rejected)
6363@section ( " mysection " ) let invalidClosure1 = { }
64- // expected-error@-1{{closures not supported in a '@const' expression}}
64+ // expected-error@-1{{closures not supported in a constant expression}}
6565@section ( " mysection " ) let invalidClosure2 = { return 42 }
66- // expected-error@-1{{closures not supported in a '@const' expression}}
66+ // expected-error@-1{{closures not supported in a constant expression}}
6767
6868struct S { }
6969enum E { case a }
@@ -73,13 +73,13 @@ enum E { case a }
7373
7474// invalid metatype references
7575@section ( " mysection " ) let invalidMetatype1 = Int . self. self
76- // expected-error@-1{{type expressions not supported in a '@const' expression}}
76+ // expected-error@-1{{type expressions not supported in a constant expression}}
7777@section ( " mysection " ) let invalidMetatype2 = ( 1 == 1 ? Int . self : Int . self) . self
78- // expected-error@-1{{type expressions not supported in a '@const' expression}}
78+ // expected-error@-1{{type expressions not supported in a constant expression}}
7979@section ( " mysection " ) let invalidMetatype3 = Array< Int> . self // generic
80- // expected-error@-1{{type expressions not supported in a '@const' expression}}
80+ // expected-error@-1{{type expressions not supported in a constant expression}}
8181@section ( " mysection " ) let invalidMetatype4 = Mirror . self // resilient
82- // expected-error@-1{{type expressions not supported in a '@const' expression}}
82+ // expected-error@-1{{type expressions not supported in a constant expression}}
8383
8484// tuples
8585@section ( " mysection " ) let tuple1 = ( 1 , 2 , 3 , 2.718 , true ) // ok
@@ -88,35 +88,35 @@ enum E { case a }
8888
8989// invalid tuples (should be rejected)
9090@section ( " mysection " ) let invalidTuple1 = ( 1 , 2 , Int . max)
91- // expected-error@-1{{not supported in a '@const' expression}}
91+ // expected-error@-1{{not supported in a constant expression}}
9292@section ( " mysection " ) let invalidTuple2 = ( 1 + 1 , 2 )
93- // expected-error@-1{{unsupported operator in a '@const' expression}}
93+ // expected-error@-1{{unsupported operator in a constant expression}}
9494
9595let someVar = 42
9696
9797// variables (should be rejected)
9898@section ( " mysection " ) let invalidVarRef = someVar
99- // expected-error@-1{{unable to resolve variable reference in a '@const' expression}}
99+ // expected-error@-1{{unable to resolve variable reference in a constant expression}}
100100
101101struct MyCustomExpressibleByIntegerLiteral : ExpressibleByIntegerLiteral {
102102 init ( integerLiteral value: Int ) { }
103103}
104104
105105// custom types (should be rejected)
106106@section ( " mysection " ) let invalidCustomType1 : MyCustomExpressibleByIntegerLiteral = 42
107- // expected-error@-1{{unsupported type in a '@const' expression}}
107+ // expected-error@-1{{unsupported type in a constant expression}}
108108@section ( " mysection " ) let invalidCustomType2 : E = E . a
109- // expected-error@-1{{not supported in a '@const' expression}}
109+ // expected-error@-1{{not supported in a constant expression}}
110110@section ( " mysection " ) let invalidCustomType3 : S = S ( )
111- // expected-error@-1{{not supported in a '@const' expression}}
111+ // expected-error@-1{{not supported in a constant expression}}
112112
113113// other standard types (should be rejected)
114114@section ( " mysection " ) let invalidString = " hello "
115- // expected-error@-1{{unsupported type in a '@const' expression}}
115+ // expected-error@-1{{unsupported type in a constant expression}}
116116@section ( " mysection " ) let invalidArray = [ 1 , 2 , 3 ]
117- // expected-error@-1{{unsupported type in a '@const' expression}}
117+ // expected-error@-1{{unsupported type in a constant expression}}
118118@section ( " mysection " ) let invalidDict = [ " key " : " value " ]
119- // expected-error@-1{{not supported in a '@const' expression}}
119+ // expected-error@-1{{not supported in a constant expression}}
120120
121121// inline array
122122@available ( SwiftStdlib 6 . 2 , * )
@@ -125,20 +125,20 @@ struct MyCustomExpressibleByIntegerLiteral: ExpressibleByIntegerLiteral {
125125// invalid inline array (should be rejected)
126126@available ( SwiftStdlib 6 . 2 , * )
127127@section ( " mysection " ) let invalidInlineArray : InlineArray = [ 1 , 2 , 3 , Int . max]
128- // expected-error@-1{{not supported in a '@const' expression}}
128+ // expected-error@-1{{not supported in a constant expression}}
129129
130130// optionals (should be rejected)
131131@section ( " mysection " ) let optional1 : Int ? = 42
132- // expected-error@-1{{unsupported type in a '@const' expression}}
132+ // expected-error@-1{{unsupported type in a constant expression}}
133133@section ( " mysection " ) let optional2 : Int ? = nil
134- // expected-error@-1{{unsupported type in a '@const' expression}}
134+ // expected-error@-1{{unsupported type in a constant expression}}
135135@section ( " mysection " ) let optional3 : Double ? = 3.14
136- // expected-error@-1{{unsupported type in a '@const' expression}}
136+ // expected-error@-1{{unsupported type in a constant expression}}
137137@section ( " mysection " ) let optional4 : Bool ? = true
138- // expected-error@-1{{unsupported type in a '@const' expression}}
138+ // expected-error@-1{{unsupported type in a constant expression}}
139139@section ( " mysection " ) let optional5 : Bool ? = false
140- // expected-error@-1{{unsupported type in a '@const' expression}}
140+ // expected-error@-1{{unsupported type in a constant expression}}
141141@section ( " mysection " ) let optional6 : Int ? = 1 + 1
142- // expected-error@-1{{unsupported type in a '@const' expression}}
142+ // expected-error@-1{{unsupported type in a constant expression}}
143143@section ( " mysection " ) let optional7 : Int ? = Int . max
144- // expected-error@-1{{unsupported type in a '@const' expression}}
144+ // expected-error@-1{{unsupported type in a constant expression}}
0 commit comments