|
21 | 21 | @section("mysection") let boolLiteral1 = true // ok |
22 | 22 | @section("mysection") let boolLiteral2 = false // ok |
23 | 23 |
|
| 24 | +// magic literals |
| 25 | +@section("mysection") let invalidNonLiteral4 = #line |
| 26 | + |
24 | 27 | // operators (should be rejected) |
25 | 28 | @section("mysection") let invalidOperator1 = 1 + 1 |
26 | 29 | // expected-error@-1{{unsupported operator in a '@const' expression}} |
|
31 | 34 |
|
32 | 35 | // non-literal expressions (should be rejected) |
33 | 36 | @section("mysection") let invalidNonLiteral1 = Int.max |
34 | | -// expected-error@-1{{unable to resolve variable reference in a '@const' expression}} |
| 37 | +// expected-error@-1{{not supported in a '@const' expression}} |
35 | 38 | @section("mysection") let invalidNonLiteral2 = UInt8(42) |
36 | 39 | // expected-error@-1{{not supported in a '@const' expression}} |
| 40 | +@section("mysection") let invalidNonLiteral3 = true.hashValue |
| 41 | +// expected-error@-1{{not supported in a '@const' expression}} |
37 | 42 |
|
38 | 43 | func foo() -> Int { return 42 } |
39 | 44 | func bar(x: Int) -> String { return "test" } |
@@ -83,7 +88,7 @@ enum E { case a } |
83 | 88 |
|
84 | 89 | // invalid tuples (should be rejected) |
85 | 90 | @section("mysection") let invalidTuple1 = (1, 2, Int.max) |
86 | | -// expected-error@-1{{unable to resolve variable reference in a '@const' expression}} |
| 91 | +// expected-error@-1{{not supported in a '@const' expression}} |
87 | 92 | @section("mysection") let invalidTuple2 = (1 + 1, 2) |
88 | 93 | // expected-error@-1{{unsupported operator in a '@const' expression}} |
89 | 94 |
|
@@ -120,7 +125,7 @@ struct MyCustomExpressibleByIntegerLiteral: ExpressibleByIntegerLiteral { |
120 | 125 | // invalid inline array (should be rejected) |
121 | 126 | @available(SwiftStdlib 6.2, *) |
122 | 127 | @section("mysection") let invalidInlineArray: InlineArray = [1, 2, 3, Int.max] |
123 | | -// expected-error@-1{{unable to resolve variable reference in a '@const' expression}} |
| 128 | +// expected-error@-1{{not supported in a '@const' expression}} |
124 | 129 |
|
125 | 130 | // optionals (should be rejected) |
126 | 131 | @section("mysection") let optional1: Int? = 42 |
|
0 commit comments