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 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037
|
(* TEST
expect;
*)
(********************************** Equality **********************************)
module M : sig
type ('a, 'b) t = 'a * 'b
end = struct
type ('a, 'b) t = 'a * 'a
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type ('a, 'b) t = 'a * 'a
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type ('a, 'b) t = 'a * 'a end
is not included in
sig type ('a, 'b) t = 'a * 'b end
Type declarations do not match:
type ('a, 'b) t = 'a * 'a
is not included in
type ('a, 'b) t = 'a * 'b
The type "'a * 'a" is not equal to the type "'a * 'b"
Type "'a" is not equal to type "'b"
|}];;
module M : sig
type ('a, 'b) t = 'a * 'a
end = struct
type ('a, 'b) t = 'a * 'b
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type ('a, 'b) t = 'a * 'b
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type ('a, 'b) t = 'a * 'b end
is not included in
sig type ('a, 'b) t = 'a * 'a end
Type declarations do not match:
type ('a, 'b) t = 'a * 'b
is not included in
type ('a, 'b) t = 'a * 'a
The type "'a * 'b" is not equal to the type "'a * 'a"
Type "'b" is not equal to type "'a"
|}];;
type 'a x
module M: sig
type ('a,'b,'c) t = ('a * 'b * 'c * 'b * 'a) x
end = struct
type ('b,'c,'a) t = ('b * 'c * 'a * 'c * 'a) x
end
[%%expect{|
type 'a x
Lines 4-6, characters 6-3:
4 | ......struct
5 | type ('b,'c,'a) t = ('b * 'c * 'a * 'c * 'a) x
6 | end
Error: Signature mismatch:
Modules do not match:
sig type ('b, 'c, 'a) t = ('b * 'c * 'a * 'c * 'a) x end
is not included in
sig type ('a, 'b, 'c) t = ('a * 'b * 'c * 'b * 'a) x end
Type declarations do not match:
type ('b, 'c, 'a) t = ('b * 'c * 'a * 'c * 'a) x
is not included in
type ('a, 'b, 'c) t = ('a * 'b * 'c * 'b * 'a) x
The type "('b * 'c * 'a * 'c * 'a) x" is not equal to the type
"('b * 'c * 'a * 'c * 'b) x"
Type "'a" is not equal to type "'b"
|}]
module M : sig
type t = <m : 'b. 'b * ('b * <m:'c. 'c * 'bar> as 'bar)>
end = struct
type t = <m : 'a. 'a * ('a * 'foo)> as 'foo
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = <m : 'a. 'a * ('a * 'foo)> as 'foo
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = < m : 'a. 'a * ('a * 'b) > as 'b end
is not included in
sig type t = < m : 'b. 'b * ('b * < m : 'c. 'c * 'a > as 'a) > end
Type declarations do not match:
type t = < m : 'a. 'a * ('a * 'b) > as 'b
is not included in
type t = < m : 'b. 'b * ('b * < m : 'c. 'c * 'a > as 'a) >
The type "< m : 'a. 'a * ('a * 'd) > as 'd" is not equal to the type
"< m : 'b. 'b * ('b * < m : 'c. 'c * 'e > as 'e) >"
The method "m" has type "'a. 'a * ('a * < m : 'a. 'f >) as 'f",
but the expected method type was "'c. 'c * ('b * < m : 'c. 'g >) as 'g"
The universal variable "'b" would escape its scope
|}];;
type s = private < m : int; .. >;;
[%%expect{|
type s = private < m : int; .. >
|}];;
module M : sig
type t = s
end = struct
type t = <m : int>
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = <m : int>
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = < m : int > end
is not included in
sig type t = s end
Type declarations do not match:
type t = < m : int >
is not included in
type t = s
The type "< m : int >" is not equal to the type "s"
The second object type has an abstract row, it cannot be closed
|}];;
module M : sig
type t = <m : int>
end = struct
type t = s
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = s
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = s end
is not included in
sig type t = < m : int > end
Type declarations do not match:
type t = s
is not included in
type t = < m : int >
The type "s" is not equal to the type "< m : int >"
The first object type has an abstract row, it cannot be closed
|}];;
module M : sig
type t =
| Foo of (int)*float
end = struct
type t =
| Foo of (int*int)*float
end;;
[%%expect{|
Lines 4-7, characters 6-3:
4 | ......struct
5 | type t =
6 | | Foo of (int*int)*float
7 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = Foo of (int * int) * float end
is not included in
sig type t = Foo of int * float end
Type declarations do not match:
type t = Foo of (int * int) * float
is not included in
type t = Foo of int * float
Constructors do not match:
"Foo of (int * int) * float"
is not the same as:
"Foo of int * float"
The type "int * int" is not equal to the type "int"
|}];;
module M : sig
type t = (int * float)
end = struct
type t = (int * float * int)
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = (int * float * int)
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = int * float * int end
is not included in
sig type t = int * float end
Type declarations do not match:
type t = int * float * int
is not included in
type t = int * float
The type "int * float * int" is not equal to the type "int * float"
|}];;
module M : sig
type t = <n : int; m : float>
end = struct
type t = <n : int; f : float>
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = <n : int; f : float>
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = < f : float; n : int > end
is not included in
sig type t = < m : float; n : int > end
Type declarations do not match:
type t = < f : float; n : int >
is not included in
type t = < m : float; n : int >
The type "< f : float; n : int >" is not equal to the type
"< m : float; n : int >"
The second object type has no method "f"
|}];;
module M : sig
type t = <n : int; m : float>
end = struct
type t = <n : int>
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = <n : int>
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = < n : int > end
is not included in
sig type t = < m : float; n : int > end
Type declarations do not match:
type t = < n : int >
is not included in
type t = < m : float; n : int >
The type "< n : int >" is not equal to the type "< m : float; n : int >"
The first object type has no method "m"
|}];;
module M4 : sig
type t = <n : int; m : float * int>
end = struct
type t = <n : int; m : int>
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = <n : int; m : int>
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = < m : int; n : int > end
is not included in
sig type t = < m : float * int; n : int > end
Type declarations do not match:
type t = < m : int; n : int >
is not included in
type t = < m : float * int; n : int >
The type "< m : int; n : int >" is not equal to the type
"< m : float * int; n : int >"
The method "m" has type "int", but the expected method type was
"float * int"
|}];;
module M4 : sig
type t =
| Foo of [`Foo of string | `Bar of string]
end = struct
type t =
| Foo of [`Bar of string]
end;;
[%%expect{|
Lines 4-7, characters 6-3:
4 | ......struct
5 | type t =
6 | | Foo of [`Bar of string]
7 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = Foo of [ `Bar of string ] end
is not included in
sig type t = Foo of [ `Bar of string | `Foo of string ] end
Type declarations do not match:
type t = Foo of [ `Bar of string ]
is not included in
type t = Foo of [ `Bar of string | `Foo of string ]
Constructors do not match:
"Foo of [ `Bar of string ]"
is not the same as:
"Foo of [ `Bar of string | `Foo of string ]"
The type "[ `Bar of string ]" is not equal to the type
"[ `Bar of string | `Foo of string ]"
The first variant type does not allow tag(s) "`Foo"
|}];;
module M : sig
type t = private [`C of int]
end = struct
type t = private [`C]
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = private [`C]
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = private [ `C ] end
is not included in
sig type t = private [ `C of int ] end
Type declarations do not match:
type t = private [ `C ]
is not included in
type t = private [ `C of int ]
The type "[ `C ]" is not equal to the type "[ `C of int ]"
Types for tag "`C" are incompatible
|}];;
module M : sig
type t = private [`C]
end = struct
type t = private [`C of int]
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = private [`C of int]
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = private [ `C of int ] end
is not included in
sig type t = private [ `C ] end
Type declarations do not match:
type t = private [ `C of int ]
is not included in
type t = private [ `C ]
The type "[ `C of int ]" is not equal to the type "[ `C ]"
Types for tag "`C" are incompatible
|}];;
module M : sig
type t = [`C of [< `A] | `C of [`A]]
end = struct
type t = [`C of [< `A | `B] | `C of [`A]]
end;;
[%%expect{|
module M : sig type t = [ `C of [ `A ] ] end
|}];;
module M : sig
type t = private [> `A of int]
end = struct
type t = private [`A of int]
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = private [`A of int]
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = private [ `A of int ] end
is not included in
sig type t = private [> `A of int ] end
Type declarations do not match:
type t = private [ `A of int ]
is not included in
type t = private [> `A of int ]
The type "[ `A of int ]" is not equal to the type "[> `A of int ]"
The second variant type is open and the first is not
|}];;
module M : sig
type t = private [`A of int]
end = struct
type t = private [> `A of int]
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = private [> `A of int]
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = private [> `A of int ] end
is not included in
sig type t = private [ `A of int ] end
Type declarations do not match:
type t = private [> `A of int ]
is not included in
type t = private [ `A of int ]
The type "[> `A of int ]" is not equal to the type "[ `A of int ]"
The first variant type is open and the second is not
|}];;
module M : sig
type 'a t = [> `A of int | `B of int] as 'a
end = struct
type 'a t = [> `A of int] as 'a
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type 'a t = [> `A of int] as 'a
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type 'a t = 'a constraint 'a = [> `A of int ] end
is not included in
sig type 'a t = 'a constraint 'a = [> `A of int | `B of int ] end
Type declarations do not match:
type 'a t = 'a constraint 'a = [> `A of int ]
is not included in
type 'a t = 'a constraint 'a = [> `A of int | `B of int ]
The type "[> `A of int ]" is not equal to the type
"[> `A of int | `B of int ]"
The first variant type does not allow tag(s) "`B"
|}];;
module M : sig
type 'a t = [> `A of int] as 'a
end = struct
type 'a t = [> `A of int | `C of float] as 'a
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type 'a t = [> `A of int | `C of float] as 'a
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type 'a t = 'a constraint 'a = [> `A of int | `C of float ] end
is not included in
sig type 'a t = 'a constraint 'a = [> `A of int ] end
Type declarations do not match:
type 'a t = 'a constraint 'a = [> `A of int | `C of float ]
is not included in
type 'a t = 'a constraint 'a = [> `A of int ]
The type "[> `A of int | `C of float ]" is not equal to the type
"[> `A of int ]"
The second variant type does not allow tag(s) "`C"
|}];;
module M : sig
type t = [`C of [< `A | `B] | `C of [`A]]
end = struct
type t = [`C of [< `A] | `C of [`A]]
end;;
[%%expect{|
module M : sig type t = [ `C of [ `A ] ] end
|}];;
module M : sig
type t = private [< `C]
end = struct
type t = private [< `C of int&float]
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = private [< `C of int&float]
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = private [< `C of int & float ] end
is not included in
sig type t = private [< `C ] end
Type declarations do not match:
type t = private [< `C of int & float ]
is not included in
type t = private [< `C ]
Types for tag `C are incompatible
|}];;
(********************************** Moregen ***********************************)
module type T = sig
type t
end
module Int = struct
type t = int
end
module type S = sig
module Choice : T
val r : Choice.t list ref ref
end
module Force (X : functor () -> S) = struct end
module Choose () = struct
module Choice =
(val (module Int : T))
let r = ref (ref [])
end
module Ignore = Force(Choose)
[%%expect{|
module type T = sig type t end
module Int : sig type t = int end
module type S = sig module Choice : T val r : Choice.t list ref ref end
module Force : (X : () -> S) -> sig end
module Choose : () -> sig module Choice : T val r : '_weak1 list ref ref end
Line 17, characters 16-29:
17 | module Ignore = Force(Choose)
^^^^^^^^^^^^^
Error: Modules do not match:
() -> sig module Choice : T val r : '_weak1 list ref ref end
is not included in () -> S
Modules do not match:
sig module Choice : T val r : '_weak1 list ref ref end
is not included in
S
Values do not match:
val r : '_weak1 list ref ref
is not included in
val r : Choice.t list ref ref
The type "'_weak1 list ref ref" is not compatible with the type
"Choice.t list ref ref"
The type constructor "Choice.t" would escape its scope
|}];;
module O = struct
module type s
module M: sig
val f: (module s) -> unit
end = struct
module type s
let f (module X:s) = ()
end
end;;
[%%expect{|
Lines 5-8, characters 8-5:
5 | ........struct
6 | module type s
7 | let f (module X:s) = ()
8 | end
Error: Signature mismatch:
Modules do not match:
sig module type s val f : (module s) -> unit end
is not included in
sig val f : (module s) -> unit end
Values do not match:
val f : (module s) -> unit
is not included in
val f : (module s/2) -> unit
The type "(module s) -> unit" is not compatible with the type
"(module s/2) -> unit"
Modules do not match: s is not included in s/2
Line 6, characters 4-17:
Definition of module type "s"
Line 2, characters 2-15:
Definition of module type "s/2"
|}];;
module M : sig
val f : (<m : 'b. ('b * <m: 'c. 'c * 'bar> as 'bar)>) -> unit
end = struct
let f (x : <m : 'a. ('a * 'foo)> as 'foo) = ()
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | let f (x : <m : 'a. ('a * 'foo)> as 'foo) = ()
5 | end..
Error: Signature mismatch:
Modules do not match:
sig val f : (< m : 'a. 'a * 'b > as 'b) -> unit end
is not included in
sig val f : < m : 'b. 'b * < m : 'c. 'c * 'a > as 'a > -> unit end
Values do not match:
val f : (< m : 'a. 'a * 'b > as 'b) -> unit
is not included in
val f : < m : 'b. 'b * < m : 'c. 'c * 'a > as 'a > -> unit
The type "(< m : 'a. 'a * 'd > as 'd) -> unit"
is not compatible with the type
"< m : 'b. 'b * < m : 'c. 'c * 'e > as 'e > -> unit"
The method "m" has type "'a. 'a * < m : 'a. 'f > as 'f",
but the expected method type was "'c. 'c * ('b * < m : 'c. 'g >) as 'g"
The universal variable "'b" would escape its scope
|}];;
type s = private < m : int; .. >;;
module M : sig
val f : s -> s
end = struct
let f (x : <m : int>) = x
end;;
[%%expect{|
type s = private < m : int; .. >
Lines 5-7, characters 6-3:
5 | ......struct
6 | let f (x : <m : int>) = x
7 | end..
Error: Signature mismatch:
Modules do not match:
sig val f : < m : int > -> < m : int > end
is not included in
sig val f : s -> s end
Values do not match:
val f : < m : int > -> < m : int >
is not included in
val f : s -> s
The type "< m : int > -> < m : int >" is not compatible with the type
"s -> s"
Type "< m : int >" is not compatible with type "s" = "< m : int; .. >"
The second object type has an abstract row, it cannot be closed
|}];;
module M : sig
val f : 'a -> float
end = struct
let f : 'b -> int = fun _ -> 0
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | let f : 'b -> int = fun _ -> 0
5 | end..
Error: Signature mismatch:
Modules do not match:
sig val f : 'b -> int end
is not included in
sig val f : 'a -> float end
Values do not match:
val f : 'b -> int
is not included in
val f : 'a -> float
The type "'a -> int" is not compatible with the type "'a -> float"
Type "int" is not compatible with type "float"
|}]
module M : sig
val x : 'a list ref
end = struct
let x = ref []
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | let x = ref []
5 | end..
Error: Signature mismatch:
Modules do not match:
sig val x : '_weak2 list ref end
is not included in
sig val x : 'a list ref end
Values do not match:
val x : '_weak2 list ref
is not included in
val x : 'a list ref
The type "'_weak2 list ref" is not compatible with the type "'a list ref"
Type "'_weak2" is not compatible with type "'a"
|}];;
module M = struct let r = ref [] end;;
type t;;
module N : sig val r : t list ref end = M;;
[%%expect{|
module M : sig val r : '_weak3 list ref end
type t
Line 3, characters 40-41:
3 | module N : sig val r : t list ref end = M;;
^
Error: Signature mismatch:
Modules do not match:
sig val r : '_weak3 list ref end
is not included in
sig val r : t list ref end
Values do not match:
val r : '_weak3 list ref
is not included in
val r : t list ref
The type "'_weak3 list ref" is not compatible with the type "t list ref"
The type constructor "t" would escape its scope
|}];;
type (_, _) eq = Refl : ('a, 'a) eq;;
module T : sig
type t
type s
val eq : (t, s) eq
end = struct
type t = int
type s = int
let eq = Refl
end;;
module M = struct let r = ref [] end;;
let foo p (e : (T.t, T.s) eq) (x : T.t) (y : T.s) =
match e with
| Refl ->
let z = if p then x else y in
let module N = struct
module type S = module type of struct let r = ref [z] end
end in
let module O : N.S = M in
();;
[%%expect{|
type (_, _) eq = Refl : ('a, 'a) eq
module T : sig type t type s val eq : (t, s) eq end
module M : sig val r : '_weak4 list ref end
Line 22, characters 25-26:
22 | let module O : N.S = M in
^
Error: Signature mismatch:
Modules do not match:
sig val r : '_weak4 list ref end
is not included in
N.S
Values do not match:
val r : '_weak4 list ref
is not included in
val r : T.t list ref
The type "'_weak4 list ref" is not compatible with the type "T.t list ref"
This instance of "T.t" is ambiguous:
it would escape the scope of its equation
|}];;
module M: sig
val f : int -> float
end = struct
let f (x : 'a) = x
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | let f (x : 'a) = x
5 | end..
Error: Signature mismatch:
Modules do not match:
sig val f : 'a -> 'a end
is not included in
sig val f : int -> float end
Values do not match:
val f : 'a -> 'a
is not included in
val f : int -> float
The type "int -> int" is not compatible with the type "int -> float"
Type "int" is not compatible with type "float"
|}];;
module M: sig
val f : (int * float * int) -> (int -> int)
end = struct
let f (x : (int * int)) = x
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | let f (x : (int * int)) = x
5 | end..
Error: Signature mismatch:
Modules do not match:
sig val f : int * int -> int * int end
is not included in
sig val f : int * float * int -> int -> int end
Values do not match:
val f : int * int -> int * int
is not included in
val f : int * float * int -> int -> int
The type "int * int -> int * int" is not compatible with the type
"int * float * int -> int -> int"
Type "int * int" is not compatible with type "int * float * int"
|}];;
module M: sig
val f : <m : int; n : float> -> <m : int; n : float>
end = struct
let f (x : <m : int; f : float>) = x
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | let f (x : <m : int; f : float>) = x
5 | end..
Error: Signature mismatch:
Modules do not match:
sig val f : < f : float; m : int > -> < f : float; m : int > end
is not included in
sig val f : < m : int; n : float > -> < m : int; n : float > end
Values do not match:
val f : < f : float; m : int > -> < f : float; m : int >
is not included in
val f : < m : int; n : float > -> < m : int; n : float >
The type "< f : float; m : int > -> < f : float; m : int >"
is not compatible with the type
"< m : int; n : float > -> < m : int; n : float >"
The second object type has no method "f"
|}];;
module M : sig
val f : [`Foo] -> unit
end = struct
let f (x : [ `Foo | `Bar]) = ()
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | let f (x : [ `Foo | `Bar]) = ()
5 | end..
Error: Signature mismatch:
Modules do not match:
sig val f : [ `Bar | `Foo ] -> unit end
is not included in
sig val f : [ `Foo ] -> unit end
Values do not match:
val f : [ `Bar | `Foo ] -> unit
is not included in
val f : [ `Foo ] -> unit
The type "[ `Bar | `Foo ] -> unit" is not compatible with the type
"[ `Foo ] -> unit"
The second variant type does not allow tag(s) "`Bar"
|}];;
module M : sig
val f : [>`Foo] -> unit
end = struct
let f (x : [< `Foo]) = ()
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | let f (x : [< `Foo]) = ()
5 | end..
Error: Signature mismatch:
Modules do not match:
sig val f : [< `Foo ] -> unit end
is not included in
sig val f : [> `Foo ] -> unit end
Values do not match:
val f : [< `Foo ] -> unit
is not included in
val f : [> `Foo ] -> unit
The type "[< `Foo ] -> unit" is not compatible with the type
"[> `Foo ] -> unit"
The second variant type is open and the first is not
|}];;
module M : sig
val f : [< `Foo | `Bar] -> unit
end = struct
let f (x : [< `Foo]) = ()
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | let f (x : [< `Foo]) = ()
5 | end..
Error: Signature mismatch:
Modules do not match:
sig val f : [< `Foo ] -> unit end
is not included in
sig val f : [< `Bar | `Foo ] -> unit end
Values do not match:
val f : [< `Foo ] -> unit
is not included in
val f : [< `Bar | `Foo ] -> unit
The type "[< `Foo ] -> unit" is not compatible with the type
"[< `Bar | `Foo ] -> unit"
The first variant type does not allow tag(s) "`Bar"
|}];;
module M : sig
val f : < m : [< `Foo]> -> unit
end = struct
let f (x : < m : 'a. [< `Foo] as 'a >) = ()
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | let f (x : < m : 'a. [< `Foo] as 'a >) = ()
5 | end..
Error: Signature mismatch:
Modules do not match:
sig val f : < m : 'a. [< `Foo ] as 'a > -> unit end
is not included in
sig val f : < m : [< `Foo ] > -> unit end
Values do not match:
val f : < m : 'a. [< `Foo ] as 'a > -> unit
is not included in
val f : < m : [< `Foo ] > -> unit
The type "< m : 'a. [< `Foo ] as 'a > -> unit"
is not compatible with the type "< m : [< `Foo ] > -> unit"
The method "m" has type "'b. [< `Foo ] as 'b",
but the expected method type was "[< `Foo ]"
|}];;
module M : sig
val f : < m : 'a. [< `Foo] as 'a > -> unit
end = struct
let f (x : < m : [`Foo]>) = ()
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | let f (x : < m : [`Foo]>) = ()
5 | end..
Error: Signature mismatch:
Modules do not match:
sig val f : < m : [ `Foo ] > -> unit end
is not included in
sig val f : < m : 'a. [< `Foo ] as 'a > -> unit end
Values do not match:
val f : < m : [ `Foo ] > -> unit
is not included in
val f : < m : 'a. [< `Foo ] as 'a > -> unit
The type "< m : [ `Foo ] > -> unit" is not compatible with the type
"< m : 'a. [< `Foo ] as 'a > -> unit"
The method "m" has type "[ `Foo ]", but the expected method type was
"'b. [< `Foo ] as 'b"
|}];;
module M : sig
val f : [< `C] -> unit
end = struct
let f (x : [< `C of int&float]) = ()
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | let f (x : [< `C of int&float]) = ()
5 | end..
Error: Signature mismatch:
Modules do not match:
sig val f : [< `C of int & float ] -> unit end
is not included in
sig val f : [< `C ] -> unit end
Values do not match:
val f : [< `C of int & float ] -> unit
is not included in
val f : [< `C ] -> unit
The type "[< `C of & int & float ] -> unit"
is not compatible with the type "[< `C ] -> unit"
Types for tag "`C" are incompatible
|}];;
module M : sig
val f : [`Foo] -> unit
end = struct
let f (x : [`Foo of int]) = ()
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | let f (x : [`Foo of int]) = ()
5 | end..
Error: Signature mismatch:
Modules do not match:
sig val f : [ `Foo of int ] -> unit end
is not included in
sig val f : [ `Foo ] -> unit end
Values do not match:
val f : [ `Foo of int ] -> unit
is not included in
val f : [ `Foo ] -> unit
The type "[ `Foo of int ] -> unit" is not compatible with the type
"[ `Foo ] -> unit"
Types for tag "`Foo" are incompatible
|}];;
module M : sig
val f : [`Foo of int] -> unit
end = struct
let f (x : [`Foo]) = ()
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | let f (x : [`Foo]) = ()
5 | end..
Error: Signature mismatch:
Modules do not match:
sig val f : [ `Foo ] -> unit end
is not included in
sig val f : [ `Foo of int ] -> unit end
Values do not match:
val f : [ `Foo ] -> unit
is not included in
val f : [ `Foo of int ] -> unit
The type "[ `Foo ] -> unit" is not compatible with the type
"[ `Foo of int ] -> unit"
Types for tag "`Foo" are incompatible
|}];;
module M : sig
val f : [< `Foo | `Bar | `Baz] -> unit
end = struct
let f (x : [< `Foo | `Bar | `Baz]) = ()
end;;
[%%expect{|
module M : sig val f : [< `Bar | `Baz | `Foo ] -> unit end
|}];;
module M : sig
val f : [< `Foo | `Bar | `Baz] -> unit
end = struct
let f (x : [> `Foo | `Bar]) = ()
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | let f (x : [> `Foo | `Bar]) = ()
5 | end..
Error: Signature mismatch:
Modules do not match:
sig val f : [> `Bar | `Foo ] -> unit end
is not included in
sig val f : [< `Bar | `Baz | `Foo ] -> unit end
Values do not match:
val f : [> `Bar | `Foo ] -> unit
is not included in
val f : [< `Bar | `Baz | `Foo ] -> unit
The type "[> `Bar | `Foo ] -> unit" is not compatible with the type
"[< `Bar | `Baz | `Foo ] -> unit"
The tag "`Foo" is guaranteed to be present in the first variant type,
but not in the second
|}];;
(******************************* Type manifests *******************************)
module M : sig
type t = private [< `A | `B]
end = struct
type t = [`C]
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = [`C]
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = [ `C ] end
is not included in
sig type t = private [< `A | `B ] end
Type declarations do not match:
type t = [ `C ]
is not included in
type t = private [< `A | `B ]
The constructor "C" is only present in the second declaration.
|}];;
module M : sig
type t = private [< `A | `B]
end = struct
type t = private [> `A]
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = private [> `A]
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = private [> `A ] end
is not included in
sig type t = private [< `A | `B ] end
Type declarations do not match:
type t = private [> `A ]
is not included in
type t = private [< `A | `B ]
The second is private and closed, but the first is not closed
|}];;
module M : sig
type t = private [< `A | `B > `A]
end = struct
type t = [`B]
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = [`B]
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = [ `B ] end
is not included in
sig type t = private [< `A | `B > `A ] end
Type declarations do not match:
type t = [ `B ]
is not included in
type t = private [< `A | `B > `A ]
The constructor "A" is only present in the first declaration.
|}];;
module M : sig
type t = private [> `A of int]
end = struct
type t = [`A]
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = [`A]
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = [ `A ] end
is not included in
sig type t = private [> `A of int ] end
Type declarations do not match:
type t = [ `A ]
is not included in
type t = private [> `A of int ]
Types for tag `A are incompatible
|}];;
module M : sig
type t = private [< `A of int]
end = struct
type t = private [< `A of & int]
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = private [< `A of & int]
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = private [< `A of & int ] end
is not included in
sig type t = private [< `A of int ] end
Type declarations do not match:
type t = private [< `A of & int ]
is not included in
type t = private [< `A of int ]
Types for tag `A are incompatible
|}];;
module M : sig
type t = private [< `A of int]
end = struct
type t = private [< `A]
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = private [< `A]
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = private [< `A ] end
is not included in
sig type t = private [< `A of int ] end
Type declarations do not match:
type t = private [< `A ]
is not included in
type t = private [< `A of int ]
Types for tag `A are incompatible
|}];;
module M : sig
type t = private [< `A of int & float]
end = struct
type t = private [< `A]
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = private [< `A]
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = private [< `A ] end
is not included in
sig type t = private [< `A of int & float ] end
Type declarations do not match:
type t = private [< `A ]
is not included in
type t = private [< `A of int & float ]
Types for tag `A are incompatible
|}];;
module M : sig
type t = private [> `A of int]
end = struct
type t = [`A of float]
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = [`A of float]
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = [ `A of float ] end
is not included in
sig type t = private [> `A of int ] end
Type declarations do not match:
type t = [ `A of float ]
is not included in
type t = private [> `A of int ]
The type "float" is not equal to the type "int"
|}];;
module M : sig
type t = private [< `A | `B]
end = struct
type t = private [`A | `B]
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = private [`A | `B]
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = private [ `A | `B ] end
is not included in
sig type t = private [< `A | `B ] end
Type declarations do not match:
type t = private [ `A | `B ]
is not included in
type t = private [< `A | `B ]
The type "[ `A | `B ]" is not equal to the type "[< `A | `B ]"
The tag "`B" is guaranteed to be present in the first variant type,
but not in the second
|}];;
module M : sig
type t = [`A | `B]
end = struct
type t = private [`A | `B]
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = private [`A | `B]
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = private [ `A | `B ] end
is not included in
sig type t = [ `A | `B ] end
Type declarations do not match:
type t = private [ `A | `B ]
is not included in
type t = [ `A | `B ]
A private type abbreviation would be revealed.
|}];;
module M : sig
type t = private [< `A | `B > `B]
end = struct
type t = private [< `A | `B]
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = private [< `A | `B]
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = private [< `A | `B ] end
is not included in
sig type t = private [< `A | `B > `B ] end
Type declarations do not match:
type t = private [< `A | `B ]
is not included in
type t = private [< `A | `B > `B ]
The tag "`B" is present in the the second declaration,
but might not be in the the first
|}];;
module M : sig
type t = private <a : int; ..>
end = struct
type t = <b : int>
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = <b : int>
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = < b : int > end
is not included in
sig type t = private < a : int; .. > end
Type declarations do not match:
type t = < b : int >
is not included in
type t = private < a : int; .. >
The implementation is missing the method "a"
|}];;
module M : sig
type t = private <a : float; ..>
end = struct
type t = <a : int>
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = <a : int>
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = < a : int > end
is not included in
sig type t = private < a : float; .. > end
Type declarations do not match:
type t = < a : int >
is not included in
type t = private < a : float; .. >
The type "int" is not equal to the type "float"
Type "int" is not equal to type "float"
|}];;
type w = private float
type q = private (int * w)
type u = private (int * q)
module M : sig (* Confusing error message :( *)
type t = private (int * (int * int))
end = struct
type t = private u
end;;
[%%expect{|
type w = private float
type q = private int * w
type u = private int * q
Lines 6-8, characters 6-3:
6 | ......struct
7 | type t = private u
8 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = private u end
is not included in
sig type t = private int * (int * int) end
Type declarations do not match:
type t = private u
is not included in
type t = private int * (int * int)
The type "int * q" is not equal to the type "int * (int * int)"
Type "q" is not equal to type "int * int"
|}];;
type w = float
type q = (int * w)
type u = private (int * q)
module M : sig
type t = private (int * (int * int))
end = struct
type t = private u
end;;
[%%expect{|
type w = float
type q = int * w
type u = private int * q
Lines 6-8, characters 6-3:
6 | ......struct
7 | type t = private u
8 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = private u end
is not included in
sig type t = private int * (int * int) end
Type declarations do not match:
type t = private u
is not included in
type t = private int * (int * int)
The type "int * q" is not equal to the type "int * (int * int)"
Type "q" = "int * w" is not equal to type "int * int"
Type "w" = "float" is not equal to type "int"
|}];;
type s = private int
module M : sig
type t = private float
end = struct
type t = private s
end;;
[%%expect{|
type s = private int
Lines 5-7, characters 6-3:
5 | ......struct
6 | type t = private s
7 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = private s end
is not included in
sig type t = private float end
Type declarations do not match:
type t = private s
is not included in
type t = private float
The type "int" is not equal to the type "float"
|}];;
module M : sig
type t = A
end = struct
type t = private A
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = private A
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = private A end
is not included in
sig type t = A end
Type declarations do not match:
type t = private A
is not included in
type t = A
Private variant constructor(s) would be revealed.
|}];;
module M : sig
type t = A | B
end = struct
type t = private A | B
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = private A | B
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = private A | B end
is not included in
sig type t = A | B end
Type declarations do not match:
type t = private A | B
is not included in
type t = A | B
Private variant constructor(s) would be revealed.
|}];;
module M : sig
type t = A of { x : int; y : bool }
end = struct
type t = private A of { x : int; y : bool }
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = private A of { x : int; y : bool }
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = private A of { x : int; y : bool; } end
is not included in
sig type t = A of { x : int; y : bool; } end
Type declarations do not match:
type t = private A of { x : int; y : bool; }
is not included in
type t = A of { x : int; y : bool; }
Private variant constructor(s) would be revealed.
|}];;
module M : sig
type t = { x : int; y : bool }
end = struct
type t = private { x : int; y : bool }
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = private { x : int; y : bool }
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = private { x : int; y : bool; } end
is not included in
sig type t = { x : int; y : bool; } end
Type declarations do not match:
type t = private { x : int; y : bool; }
is not included in
type t = { x : int; y : bool; }
A private record constructor would be revealed.
|}];;
module M : sig
type t = A
end = struct
type t = private A | B
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = private A | B
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = private A | B end
is not included in
sig type t = A end
Type declarations do not match:
type t = private A | B
is not included in
type t = A
Private variant constructor(s) would be revealed.
|}];;
module M : sig
type t = A | B
end = struct
type t = private A
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = private A
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = private A end
is not included in
sig type t = A | B end
Type declarations do not match:
type t = private A
is not included in
type t = A | B
Private variant constructor(s) would be revealed.
|}];;
module M : sig
type t = { x : int }
end = struct
type t = private { x : int; y : bool }
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = private { x : int; y : bool }
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = private { x : int; y : bool; } end
is not included in
sig type t = { x : int; } end
Type declarations do not match:
type t = private { x : int; y : bool; }
is not included in
type t = { x : int; }
A private record constructor would be revealed.
|}];;
module M : sig
type t = { x : int; y : bool }
end = struct
type t = private { x : int }
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = private { x : int }
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = private { x : int; } end
is not included in
sig type t = { x : int; y : bool; } end
Type declarations do not match:
type t = private { x : int; }
is not included in
type t = { x : int; y : bool; }
A private record constructor would be revealed.
|}];;
module M : sig
type t = A | B
end = struct
type t = private { x : int; y : bool }
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = private { x : int; y : bool }
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = private { x : int; y : bool; } end
is not included in
sig type t = A | B end
Type declarations do not match:
type t = private { x : int; y : bool; }
is not included in
type t = A | B
The first is a record, but the second is a variant.
|}];;
module M : sig
type t = { x : int; y : bool }
end = struct
type t = private A | B
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = private A | B
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = private A | B end
is not included in
sig type t = { x : int; y : bool; } end
Type declarations do not match:
type t = private A | B
is not included in
type t = { x : int; y : bool; }
The first is a variant, but the second is a record.
|}];;
module M : sig
type t = [`A]
end = struct
type t = private [> `A | `B]
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = private [> `A | `B]
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = private [> `A | `B ] end
is not included in
sig type t = [ `A ] end
Type declarations do not match:
type t = private [> `A | `B ]
is not included in
type t = [ `A ]
A private row type would be revealed.
|}];;
module M : sig
type t = [`A]
end = struct
type t = private [< `A | `B]
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = private [< `A | `B]
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = private [< `A | `B ] end
is not included in
sig type t = [ `A ] end
Type declarations do not match:
type t = private [< `A | `B ]
is not included in
type t = [ `A ]
A private row type would be revealed.
|}];;
module M : sig
type t = [`A]
end = struct
type t = private [< `A | `B > `A]
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = private [< `A | `B > `A]
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = private [< `A | `B > `A ] end
is not included in
sig type t = [ `A ] end
Type declarations do not match:
type t = private [< `A | `B > `A ]
is not included in
type t = [ `A ]
A private row type would be revealed.
|}];;
module M : sig
type t = < m : int >
end = struct
type t = private < m : int; .. >
end;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = private < m : int; .. >
5 | end..
Error: Signature mismatch:
Modules do not match:
sig type t = private < m : int; .. > end
is not included in
sig type t = < m : int > end
Type declarations do not match:
type t = private < m : int; .. >
is not included in
type t = < m : int >
A private row type would be revealed.
|}];;
(** Unexpected recursive types *)
module M: sig
type _ t = A : (<x:'a> as 'a) -> (<y:'b> as 'b) t
end = struct
type _ t = A : (<x:'a * 'a> as 'a) -> (<y:'b> as 'b) t
end
[%%expect {|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type _ t = A : (<x:'a * 'a> as 'a) -> (<y:'b> as 'b) t
5 | end
Error: Signature mismatch:
Modules do not match:
sig
type _ t = A : (< x : 'b * 'b > as 'b) -> (< y : 'a > as 'a) t
end
is not included in
sig type _ t = A : (< x : 'b > as 'b) -> (< y : 'a > as 'a) t end
Type declarations do not match:
type _ t = A : (< x : 'b * 'b > as 'b) -> (< y : 'a > as 'a) t
is not included in
type _ t = A : (< x : 'b > as 'b) -> (< y : 'a > as 'a) t
Constructors do not match:
"A : (< x : 'b * 'b > as 'b) -> (< y : 'a > as 'a) t"
is not the same as:
"A : (< x : 'b > as 'b) -> (< y : 'a > as 'a) t"
The type "< x : 'a * 'a > as 'a" is not equal to the type
"< x : 'b > as 'b"
The method "x" has type "< x : 'c > * < x : 'c > as 'c",
but the expected method type was "< x : 'b > as 'b"
|}]
module R: sig
type t = { a: (<x:'a> as 'a) }
end = struct
type t = { a: (<x:'a * 'a> as 'a) }
end
[%%expect {|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = { a: (<x:'a * 'a> as 'a) }
5 | end
Error: Signature mismatch:
Modules do not match:
sig type t = { a : < x : 'a * 'a > as 'a; } end
is not included in
sig type t = { a : < x : 'a > as 'a; } end
Type declarations do not match:
type t = { a : < x : 'a * 'a > as 'a; }
is not included in
type t = { a : < x : 'a > as 'a; }
Fields do not match:
"a : < x : 'a * 'a > as 'a;"
is not the same as:
"a : < x : 'a > as 'a;"
The type "< x : 'a * 'a > as 'a" is not equal to the type
"< x : 'b > as 'b"
The method "x" has type "< x : 'c > * < x : 'c > as 'c",
but the expected method type was "< x : 'b > as 'b"
|}]
type _ ext = ..
module Ext: sig
type _ ext += A : (<x:'a> as 'a) -> (<y:'b> as 'b) ext
end = struct
type _ ext += A : (<x:'a * 'a> as 'a) -> (<y:'b> as 'b) ext
end
[%%expect {|
type _ ext = ..
Lines 4-6, characters 6-3:
4 | ......struct
5 | type _ ext += A : (<x:'a * 'a> as 'a) -> (<y:'b> as 'b) ext
6 | end
Error: Signature mismatch:
Modules do not match:
sig
type _ ext +=
A : (< x : 'b * 'b > as 'b) -> (< y : 'a > as 'a) ext
end
is not included in
sig
type _ ext += A : (< x : 'b > as 'b) -> (< y : 'a > as 'a) ext
end
Extension declarations do not match:
type _ ext += A : (< x : 'b * 'b > as 'b) -> (< y : 'a > as 'a) ext
is not included in
type _ ext += A : (< x : 'b > as 'b) -> (< y : 'a > as 'a) ext
Constructors do not match:
"A : (< x : 'b * 'b > as 'b) -> (< y : 'a > as 'a) ext"
is not the same as:
"A : (< x : 'b > as 'b) -> (< y : 'a > as 'a) ext"
The type "< x : 'a * 'a > as 'a" is not equal to the type
"< x : 'b > as 'b"
The method "x" has type "< x : 'c > * < x : 'c > as 'c",
but the expected method type was "< x : 'b > as 'b"
|}]
(********************************** Nested modules ****************************)
(* This test ensures that the error messages for missing bindings
are printed in a logical order, with "In module N:" mentioned
in sensible places.
*)
module M : sig
module N : sig
type t
val x : t
val y : t
end
end = struct
module N = struct
end
end
[%%expect {|
Lines 7-10, characters 6-3:
7 | ......struct
8 | module N = struct
9 | end
10 | end
Error: Signature mismatch:
Modules do not match:
sig module N : sig end end
is not included in
sig module N : sig type t val x : t val y : t end end
In module "N":
Modules do not match:
sig end
is not included in
sig type t val x : t val y : t end
In module "N":
The type "t" is required but not provided
The value "x" is required but not provided
The value "y" is required but not provided
|}];;
module Eq_label: sig
type t = int -> int
end = struct
type t = x:int -> int
end
[%%expect {|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = x:int -> int
5 | end
Error: Signature mismatch:
Modules do not match:
sig type t = x:int -> int end
is not included in
sig type t = int -> int end
Type declarations do not match:
type t = x:int -> int
is not included in
type t = int -> int
The type "x:int -> int" is not equal to the type "int -> int"
The first argument is labeled "x",
but an unlabeled argument was expected
|}]
module Eq_label2: sig
type t = y:int -> int
end = struct
type t = x:int -> int
end
[%%expect {|
Lines 3-5, characters 6-3:
3 | ......struct
4 | type t = x:int -> int
5 | end
Error: Signature mismatch:
Modules do not match:
sig type t = x:int -> int end
is not included in
sig type t = y:int -> int end
Type declarations do not match:
type t = x:int -> int
is not included in
type t = y:int -> int
The type "x:int -> int" is not equal to the type "y:int -> int"
Labels "x" and "y" do not match
|}]
module Label1 : sig
val f: int -> unit
end = struct
let f ~x = ()
end
[%%expect {|
Lines 3-5, characters 6-3:
3 | ......struct
4 | let f ~x = ()
5 | end
Error: Signature mismatch:
Modules do not match:
sig val f : x:'a -> unit end
is not included in
sig val f : int -> unit end
Values do not match:
val f : x:'a -> unit
is not included in
val f : int -> unit
The type "x:'a -> unit" is not compatible with the type "int -> unit"
The first argument is labeled "x",
but an unlabeled argument was expected
|}]
module Label2 : sig
val f: int -> unit
end = struct
let f ?x = ()
end
[%%expect {|
Line 4, characters 9-10:
4 | let f ?x = ()
^
Warning 16 [unerasable-optional-argument]: this optional argument cannot be erased.
Lines 3-5, characters 6-3:
3 | ......struct
4 | let f ?x = ()
5 | end
Error: Signature mismatch:
Modules do not match:
sig val f : ?x:'a -> unit end
is not included in
sig val f : int -> unit end
Values do not match:
val f : ?x:'a -> unit
is not included in
val f : int -> unit
The type "?x:'a -> unit" is not compatible with the type "int -> unit"
The first argument is labeled "?x",
but an unlabeled argument was expected
|}]
module Label3 : sig
val f: x:int -> unit
end = struct
let f ?x = ()
end
[%%expect {|
Line 4, characters 9-10:
4 | let f ?x = ()
^
Warning 16 [unerasable-optional-argument]: this optional argument cannot be erased.
Lines 3-5, characters 6-3:
3 | ......struct
4 | let f ?x = ()
5 | end
Error: Signature mismatch:
Modules do not match:
sig val f : ?x:'a -> unit end
is not included in
sig val f : x:int -> unit end
Values do not match:
val f : ?x:'a -> unit
is not included in
val f : x:int -> unit
The type "?x:'a -> unit" is not compatible with the type "x:int -> unit"
The label "?x" was expected to not be optional
|}]
module Label4 : sig
val f: ?x:int -> unit
end = struct
let f ?y = ()
end
[%%expect {|
Line 4, characters 9-10:
4 | let f ?y = ()
^
Warning 16 [unerasable-optional-argument]: this optional argument cannot be erased.
Lines 3-5, characters 6-3:
3 | ......struct
4 | let f ?y = ()
5 | end
Error: Signature mismatch:
Modules do not match:
sig val f : ?y:'a -> unit end
is not included in
sig val f : ?x:int -> unit end
Values do not match:
val f : ?y:'a -> unit
is not included in
val f : ?x:int -> unit
The type "?y:'a -> unit" is not compatible with the type "?x:int -> unit"
Labels "?y" and "?x" do not match
|}]
module Label5 : sig
val f: ?x:int -> unit
end = struct
let f x = ()
end
[%%expect {|
Lines 3-5, characters 6-3:
3 | ......struct
4 | let f x = ()
5 | end
Error: Signature mismatch:
Modules do not match:
sig val f : 'a -> unit end
is not included in
sig val f : ?x:int -> unit end
Values do not match:
val f : 'a -> unit
is not included in
val f : ?x:int -> unit
The type "'a -> unit" is not compatible with the type "?x:int -> unit"
A label "?x" was expected
|}]
|