File tree 1 file changed +30
-0
lines changed
1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -648,3 +648,33 @@ func TestCheckViewFunctionWithErrors(t *testing.T) {
648
648
assert .IsType (t , & sema.PurityError {}, errs [1 ])
649
649
})
650
650
}
651
+
652
+ func TestCheckInvalidFunctionSubtyping (t * testing.T ) {
653
+
654
+ t .Parallel ()
655
+
656
+ _ , err := ParseAndCheck (t , `
657
+ resource R {}
658
+
659
+ entitlement E
660
+
661
+ fun test() {
662
+ var f: fun (&R) = fun(ref: &R) {}
663
+ f = fun(ref: auth(E) &R) {}
664
+ }
665
+ ` )
666
+ errs := RequireCheckerErrors (t , err , 1 )
667
+ assert .IsType (t , & sema.TypeMismatchError {}, errs [0 ])
668
+
669
+ var errTypeMismatch * sema.TypeMismatchError
670
+ require .ErrorAs (t , err , & errTypeMismatch )
671
+ assert .Equal (t , 8 , errTypeMismatch .StartPos .Line )
672
+ assert .Equal (t ,
673
+ common .TypeID ("fun(&S.test.R):Void" ),
674
+ errTypeMismatch .ExpectedType .ID (),
675
+ )
676
+ assert .Equal (t ,
677
+ common .TypeID ("fun(auth(S.test.E)&S.test.R):Void" ),
678
+ errTypeMismatch .ActualType .ID (),
679
+ )
680
+ }
You can’t perform that action at this time.
0 commit comments