1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271
|
// Tests for fix-its on `-verify` mode.
// RUN: not %target-typecheck-verify-swift 2>&1 | %FileCheck %s
func labeledFunc(aa: Int, bb: Int) {}
func testNoneMarkerCheck() {
// CHECK: [[@LINE+1]]:87: error: A second {{{{}}none}} was found. It may only appear once in an expectation.
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{none}} {{none}}
// CHECK: [[@LINE+1]]:134: error: {{{{}}none}} must be at the end.
labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=aa}} {{none}} {{23-26=bb}}
}
func test0Fixits() {
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}}
// CHECK: [[@LINE+1]]:80: error: expected fix-it verification within braces; example: '1-2=text' or 'none'
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{}}
// CHECK: [[@LINE+1]]:81: error: expected line offset after leading '+' or '-' in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{+}}
// CHECK: [[@LINE+1]]:81: error: expected line offset after leading '+' or '-' in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{-}}
// CHECK: [[@LINE+1]]:81: error: expected '-' range separator in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{1}}
// CHECK: [[@LINE+1]]:82: error: expected colon-separated column number after line offset in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{-1}}
// CHECK: [[@LINE+1]]:82: error: expected colon-separated column number after line offset in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{+1}}
// CHECK: [[@LINE+1]]:82: error: expected column number after ':' in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{1:}}
// CHECK: [[@LINE+1]]:83: error: expected column number after ':' in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{+1:}}
// CHECK: [[@LINE+1]]:83: error: expected '-' range separator in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{1:1}}
// CHECK: [[@LINE+1]]:84: error: expected '-' range separator in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{-1:1}}
// CHECK: [[@LINE+1]]:83: error: expected column number after ':' in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{+1:-1}}
// CHECK: [[@LINE+1]]:82: error: expected line or column number in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{1-}}
// CHECK: [[@LINE+1]]:84: error: expected line or column number in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{1:1-}}
// CHECK: [[@LINE+1]]:85: error: expected line or column number in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{-1:1-}}
// CHECK: [[@LINE+1]]:83: error: expected line offset after leading '+' or '-' in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{1--}}
// CHECK: [[@LINE+1]]:83: error: expected '=' after range in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{1-1}}
// CHECK: [[@LINE+1]]:85: error: expected '=' after range in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{1:1-1}}
// CHECK: [[@LINE+1]]:86: error: expected '=' after range in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{+1:1-1}}
// CHECK: [[@LINE+1]]:83: error: expected line offset after leading '+' or '-' in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{1--:}}
// CHECK: [[@LINE+1]]:84: error: expected column number after ':' in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{1-1:}}
// CHECK: [[@LINE+1]]:86: error: expected column number after ':' in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{1:1-1:}}
// CHECK: [[@LINE+1]]:87: error: expected column number after ':' in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{+1:1-1:}}
// CHECK: [[@LINE+1]]:85: error: expected '=' after range in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{1-1:1}}
// CHECK: [[@LINE+1]]:86: error: expected '=' after range in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{1-+1:1}}
// CHECK: [[@LINE+1]]:87: error: expected '=' after range in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{1:1-1:1}}
// CHECK: [[@LINE+1]]:89: error: expected '=' after range in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{+1:1--1:1}}
// CHECK: [[@LINE+1]]:78: error: expected fix-it not seen
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{1-1=}}
// CHECK: [[@LINE+1]]:78: error: expected fix-it not seen
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{1-1=a}}
// CHECK: [[@LINE+1]]:80: error: expected line or column number in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{x-1=a}}
// CHECK: [[@LINE+1]]:82: error: expected line or column number in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{1-x=a}}
// CHECK: [[@LINE+1]]:82: error: expected column number after ':' in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{1:x-1=a}}
// CHECK: [[@LINE+1]]:80: error: expected line or column number in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{x:1-1=a}}
// CHECK: [[@LINE+1]]:81: error: expected line offset after leading '+' or '-' in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{+x:1-1=a}}
// CHECK: [[@LINE+1]]:84: error: expected column number after ':' in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{1-1:x=a}}
// CHECK: [[@LINE+1]]:82: error: expected line or column number in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{1-x:1=a}}
// CHECK: [[@LINE+1]]:83: error: expected line offset after leading '+' or '-' in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{1-+x:1=a}}
// CHECK: [[@LINE+1]]:82: error: expected column number after ':' in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{1:x-1:x=a}}
// CHECK: [[@LINE+1]]:80: error: expected line or column number in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{x:1-1:x=a}}
// CHECK: [[@LINE+1]]:81: error: expected line offset after leading '+' or '-' in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{+x:1-1:x=a}}
// CHECK: [[@LINE+1]]:82: error: expected column number after ':' in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{1:x-x:1=a}}
// CHECK: [[@LINE+1]]:82: error: expected column number after ':' in fix-it verification
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{1:x--x:1=a}}
// CHECK: [[@LINE+1]]:78: error: expected fix-it not seen
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{1:1-1:1=a}}
// CHECK: [[@LINE+1]]:78: error: expected fix-it not seen
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{1-1:1=a}}
// CHECK: [[@LINE+1]]:78: error: expected fix-it not seen
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{1:1-1=a}}
// CHECK: [[@LINE+1]]:78: error: expected fix-it not seen
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{-1:1-1=a}}
// CHECK: [[@LINE+1]]:78: error: expected fix-it not seen
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{1-+1:1=a}}
// CHECK: [[@LINE+1]]:78: error: expected fix-it not seen
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{+1:1-+1:1=a}}
// CHECK: [[@LINE+1]]:78: error: expected fix-it not seen
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{1-1=a}} {{2-2=b}}
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{none}}
// CHECK: [[@LINE+1]]:78: error: expected fix-it not seen
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{1-1=a}} {{none}}
// CHECK: [[@LINE+1]]:78: error: expected fix-it not seen
undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} {{1-1=a}} {{2-2=b}} {{none}}
}
func test1Fixits() {
labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}}
labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=aa}}
// CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}}
labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=xx}}
// CHECK: [[@LINE+1]]:134: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}}
labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=aa}} {{15-18=xx}}
// CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}}
labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=xx}} {{15-18=aa}}
// CHECK: [[@LINE+1]]:121: error: expected no fix-its; actual fix-it seen: {{{{}}15-18=aa}}
labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{none}}
labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=aa}} {{none}}
// CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}}
labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=xx}} {{none}}
// CHECK: [[@LINE+1]]:134: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}}
labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=aa}} {{15-18=xx}} {{none}}
// CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}}
labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=xx}} {{15-18=aa}} {{none}}
// CHECK-NOT: [[@LINE+1]]:{{[0-9]+}}: error:
labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{200:15-200:18=aa}}
// CHECK-NOT: [[@LINE+1]]:{{[0-9]+}}: error:
labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{202:15-18=aa}}
// CHECK-NOT: [[@LINE+1]]:{{[0-9]+}}: error:
labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-204:18=aa}}
// CHECK-NOT: [[@LINE+1]]:{{[0-9]+}}: error:
labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{-0:15-+0:18=aa}}
// CHECK-NOT: [[@LINE+1]]:{{[0-9]+}}: error:
labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15--0:18=aa}}
// CHECK-NOT: [[@LINE+1]]:{{[0-9]+}}: error:
labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {+0:15-210:18=aa}}
// CHECK-NOT: [[@LINE+1]]:{{[0-9]+}}: error:
labeledFunc(aa: 0, // expected-error {{incorrect argument label in call (have 'aa:bbx:', expected 'aa:bb:')}} {{+1:15-+1:18=bb}}
bbx: 1)
// CHECK-NOT: [[@LINE+1]]:{{[0-9]+}}: error:
labeledFunc(aa: 0, // expected-error {{incorrect argument label in call (have 'aa:bbx:', expected 'aa:bb:')}} {{216:15-+1:18=bb}}
bbx: 1)
// CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}}
labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{61:15-18=aa}}
// CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}}
labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{-1:15-18=aa}}
// CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}}
labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{+0:15--1:18=aa}}
// CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}}
labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{61:15-+1:18=aa}}
}
func unlabeledFunc(_ aa: Int) {}
func testDefaultedLineNumbers() {
// Fix-it end line defaults to first line.
// CHECK-NOT: [[@LINE+1]]:{{[0-9]+}}: error:
unlabeledFunc(aa: // expected-error {{extraneous argument label 'aa:' in call}} {{+0:17-+1:5=}}
1)
// CHECK: [[@LINE+1]]:83: error: expected fix-it not seen; actual fix-it seen: {{{{}}17-[[@LINE+2]]:5=}}
unlabeledFunc(aa: // expected-error {{extraneous argument label 'aa:' in call}} {{+0:17-5=}}
1)
// Fix-it start line defaults to diagnostic line.
// CHECK-NOT: [[@LINE+1]]:{{[0-9]+}}: error:
labeledFunc(aa: 0, // expected-error {{incorrect argument label in call (have 'aa:bbx:', expected 'aa:bb:')}} {{+1:15-+1:18=bb}}
bbx: 1)
// CHECK: [[@LINE+1]]:113: error: expected fix-it not seen; actual fix-it seen: {{{{}}[[@LINE+2]]:15-18=bb}}
labeledFunc(aa: 0, // expected-error {{incorrect argument label in call (have 'aa:bbx:', expected 'aa:bb:')}} {{15-+1:18=bb}}
bbx: 1)
}
func test2Fixits() {
labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}}
labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}}
// CHECK: [[@LINE+1]]:124: error: expected fix-it not seen; actual fix-its seen: {{{{}}15-18=aa}} {{{{}}23-26=bb}}
labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=xx}}
labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} {{23-26=bb}}
// CHECK: [[@LINE+1]]:137: error: expected fix-it not seen; actual fix-its seen: {{{{}}15-18=aa}} {{{{}}23-26=bb}}
labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} {{23-26=xx}}
// CHECK: [[@LINE+1]]:124: error: expected no fix-its; actual fix-its seen: {{{{}}15-18=aa}} {{{{}}23-26=bb}}
labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{none}}
// CHECK: [[@LINE+1]]:137: error: unexpected fix-it seen; actual fix-its seen: {{{{}}15-18=aa}} {{{{}}23-26=bb}}
labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} {{none}}
labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} {{23-26=bb}} {{none}}
// CHECK: [[@LINE+1]]:137: error: expected fix-it not seen; actual fix-its seen: {{{{}}15-18=aa}} {{{{}}23-26=bb}}
labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} {{23-26=xx}} {{none}}
}
|