You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[AST] Allow storing original expression in ErrorTypeRepr
This is useful for ArrowExpr when the sub-expressions aren't valid
TypeExprs. Rather than throwing away the AST, attach it to the
ErrorTypeRepr to ensure we can still type-check it. This ensures
semantic functionality still works correctly, and fixes a crash where
we'd stop visiting an invalid binding pattern, losing track of the
nested VarDecl.
_ =2+()-> Int // expected-error {{expected type before '->'}}
317
-
_ =()->(Int, Int).2 // expected-error {{expected type after '->'}}
316
+
// This is folded as '(2 + ()) -> Int'
317
+
_ =2+()-> Int
318
+
// expected-error@-1 {{expected type before '->'}}
319
+
// expected-error@-2 {{cannot convert value of type '()' to expected argument type 'Int'}}
320
+
321
+
_ =()->(Int, Int).2
322
+
// expected-error@-1 {{expected type after '->'}}
323
+
// expected-error@-2 {{value of tuple type '(Int, Int)' has no member '2'}}
324
+
318
325
_ =(Int)-> Int // expected-error {{expected member name or initializer call after type name}} expected-note{{use '.self' to reference the type object}}
319
326
320
327
_ =@convention(c)()-> Int // expected-error{{expected member name or initializer call after type name}} expected-note{{use '.self' to reference the type object}}
321
328
_ =1+(@convention(c)()-> Int).self // expected-error{{cannot convert value of type '(@convention(c) () -> Int).Type' to expected argument type 'Int'}}
322
-
_ =(@autoclosure()-> Int)->(Int, Int).2 // expected-error {{expected type after '->'}}
329
+
330
+
_ =(@autoclosure()-> Int)->(Int, Int).2
331
+
// expected-error@-1 {{expected type after '->'}}
332
+
// expected-error@-2 {{value of tuple type '(Int, Int)' has no member '2'}}
333
+
323
334
_ =((@autoclosure ()-> Int)->(Int, Int)).1 // expected-error {{type '(@autoclosure () -> Int) -> (Int, Int)' has no member '1'}}
let _ =[Intthrows Int](); // expected-error{{'throws' may only occur before '->'}} expected-error {{consecutive statements on a line must be separated by ';'}}
332
343
}
333
344
345
+
func testInvalidArrowWithClosure(){
346
+
_ ={ undefined ->undefined2}
347
+
// expected-error@-1 {{cannot find 'undefined' in scope}}
348
+
// expected-error@-2 {{cannot find 'undefined2' in scope}}
349
+
// expected-error@-3 {{expected type before '->'}}
350
+
// expected-error@-4 {{expected type after '->'}}
351
+
352
+
()->{letx:Int=""}
353
+
// expected-error@-1 {{expected type after '->'}}
354
+
// expected-error@-2 {{cannot convert value of type 'String' to specified type 'Int'}}
355
+
}
356
+
334
357
func compositionType(){
335
358
_ = P1 & P2 // expected-error {{expected member name or initializer call after type name}} expected-note{{use '.self'}} {{7-7=(}} {{14-14=).self}}
336
359
_ = any P1& P1 // expected-error {{expected member name or initializer call after type name}} expected-note{{use '.self'}} {{7-7=(}} {{18-18=).self}}
// {"kind":"complete","original":"2ad6764c","signature":"swift::constraints::Solution::getType(swift::KeyPathExpr const*, unsigned int) const","signatureAssert":"Assertion failed: (hasType(KP, I) && \"Expected type to have been set!\"), function getType"}
0 commit comments