File tree 1 file changed +100
-0
lines changed
1 file changed +100
-0
lines changed Original file line number Diff line number Diff line change @@ -1278,3 +1278,103 @@ fn negative_reorder() {
1278
1278
}
1279
1279
}
1280
1280
}
1281
+
1282
+ /// Test a tricky case for coinductive handling:
1283
+ ///
1284
+ /// While proving C1, we try to prove C2, which recursively requires
1285
+ /// proving C1. If you are naive, you will assume that C2 therefore
1286
+ /// holds -- but this is wrong, because C1 later fails when proving
1287
+ /// C3.
1288
+ #[ test]
1289
+ fn coinductive_unsound1 ( ) {
1290
+ test ! {
1291
+ program {
1292
+ trait C1orC2 { }
1293
+
1294
+ #[ auto]
1295
+ trait C1 { }
1296
+
1297
+ #[ auto]
1298
+ trait C2 { }
1299
+
1300
+ #[ auto]
1301
+ trait C3 { }
1302
+
1303
+ forall<T > {
1304
+ T : C1 if T : C2 , T : C3
1305
+ }
1306
+
1307
+ forall<T > {
1308
+ T : C2 if T : C1
1309
+ }
1310
+
1311
+ forall<T > {
1312
+ T : C1orC2 if T : C1
1313
+ }
1314
+
1315
+ forall<T > {
1316
+ T : C1orC2 if T : C2
1317
+ }
1318
+ }
1319
+
1320
+ goal {
1321
+ forall<X > { X : C1orC2 }
1322
+ } first 10 with max 3 {
1323
+ // FIXME(chalk#248) -- demonstrate bug in coinduction
1324
+ r"[
1325
+ Answer {
1326
+ subst: Canonical {
1327
+ value: ConstrainedSubst {
1328
+ subst: [],
1329
+ constraints: []
1330
+ }
1331
+ binders: []
1332
+ }
1333
+ delayed_literals: {}
1334
+ }
1335
+ ]"
1336
+ }
1337
+ }
1338
+ }
1339
+
1340
+ /// The only difference between this test and `coinductive_unsound1`
1341
+ /// is the order of the final `forall` clauses.
1342
+ #[ test]
1343
+ fn coinductive_unsound2 ( ) {
1344
+ test ! {
1345
+ program {
1346
+ trait C1orC2 { }
1347
+
1348
+ #[ auto]
1349
+ trait C1 { }
1350
+
1351
+ #[ auto]
1352
+ trait C2 { }
1353
+
1354
+ #[ auto]
1355
+ trait C3 { }
1356
+
1357
+ forall<T > {
1358
+ T : C1 if T : C2 , T : C3
1359
+ }
1360
+
1361
+ forall<T > {
1362
+ T : C2 if T : C1
1363
+ }
1364
+
1365
+ forall<T > {
1366
+ T : C1orC2 if T : C2
1367
+ }
1368
+
1369
+ forall<T > {
1370
+ T : C1orC2 if T : C1
1371
+ }
1372
+ }
1373
+
1374
+ goal {
1375
+ forall<X > { X : C1orC2 }
1376
+ } first 10 with max 3 {
1377
+ r"[]"
1378
+ }
1379
+ }
1380
+ }
You can’t perform that action at this time.
0 commit comments