named_constant.carbon 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/convert.carbon
  6. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/facet/named_constant.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/facet/named_constant.carbon
  12. // --- fail_todo_named_constant_in_rewrite.carbon
  13. library "[[@TEST_NAME]]";
  14. interface I {
  15. let X:! type;
  16. let Y:! type;
  17. }
  18. fn Test() {
  19. // CHECK:STDERR: fail_todo_named_constant_in_rewrite.carbon:[[@LINE+4]]:7: error: semantics TODO: `local `let :!` bindings are currently unsupported` [SemanticsTodo]
  20. // CHECK:STDERR: let Constant:! type = ();
  21. // CHECK:STDERR: ^~~~~~~~~~~~~~~
  22. // CHECK:STDERR:
  23. let Constant:! type = ();
  24. fn F(T:! I where .X = Constant) {}
  25. fn G(T:! I where .X = Constant) {
  26. // TODO: The facet type T in G should match the facet type T in F.
  27. F(T);
  28. }
  29. }
  30. // --- fail_todo_named_constant_two_levels_in_rewrite.carbon
  31. library "[[@TEST_NAME]]";
  32. interface I {
  33. let X:! type;
  34. let Y:! type;
  35. }
  36. fn Test() {
  37. // CHECK:STDERR: fail_todo_named_constant_two_levels_in_rewrite.carbon:[[@LINE+4]]:7: error: semantics TODO: `local `let :!` bindings are currently unsupported` [SemanticsTodo]
  38. // CHECK:STDERR: let Constant2:! type = ();
  39. // CHECK:STDERR: ^~~~~~~~~~~~~~~~
  40. // CHECK:STDERR:
  41. let Constant2:! type = ();
  42. let Constant:! type = (Constant2, );
  43. fn F(T:! I where .X = Constant) {}
  44. fn G(T:! I where .X = Constant) {
  45. // TODO: The facet type T in G should match the facet type T in F.
  46. F(T);
  47. }
  48. }
  49. // --- fail_todo_named_constant_in_rewrite_callee.carbon
  50. library "[[@TEST_NAME]]";
  51. interface I {
  52. let X:! type;
  53. let Y:! type;
  54. }
  55. fn Test() {
  56. // CHECK:STDERR: fail_todo_named_constant_in_rewrite_callee.carbon:[[@LINE+4]]:7: error: semantics TODO: `local `let :!` bindings are currently unsupported` [SemanticsTodo]
  57. // CHECK:STDERR: let Constant:! type = ();
  58. // CHECK:STDERR: ^~~~~~~~~~~~~~~
  59. // CHECK:STDERR:
  60. let Constant:! type = ();
  61. fn F(T:! I where .X = Constant) {}
  62. fn G(T:! I where .X = ()) {
  63. // TODO: The facet type T in G should match the facet type T in F.
  64. F(T);
  65. }
  66. }
  67. // --- fail_todo_named_constant_in_rewrite_caller.carbon
  68. library "[[@TEST_NAME]]";
  69. interface I {
  70. let X:! type;
  71. let Y:! type;
  72. }
  73. fn Test() {
  74. // CHECK:STDERR: fail_todo_named_constant_in_rewrite_caller.carbon:[[@LINE+4]]:7: error: semantics TODO: `local `let :!` bindings are currently unsupported` [SemanticsTodo]
  75. // CHECK:STDERR: let Constant:! type = ();
  76. // CHECK:STDERR: ^~~~~~~~~~~~~~~
  77. // CHECK:STDERR:
  78. let Constant:! type = ();
  79. fn F(T:! I where .X = ()) {}
  80. fn G(T:! I where .X = Constant) {
  81. // TODO: The facet type T in G should match the facet type T in F.
  82. F(T);
  83. }
  84. }
  85. // --- fail_todo_named_constant_in_nested_facet_type.carbon
  86. library "[[@TEST_NAME]]";
  87. interface I {
  88. let X:! type;
  89. let Y:! type;
  90. }
  91. fn Test() {
  92. // CHECK:STDERR: fail_todo_named_constant_in_nested_facet_type.carbon:[[@LINE+4]]:7: error: semantics TODO: `local `let :!` bindings are currently unsupported` [SemanticsTodo]
  93. // CHECK:STDERR: let Constant:! type = ();
  94. // CHECK:STDERR: ^~~~~~~~~~~~~~~
  95. // CHECK:STDERR:
  96. let Constant:! type = ();
  97. // TODO: The .Self reference in each .X should be different, there should be
  98. // no cycle here.
  99. fn F(T:! I where .X = (I where .X = Constant)) {}
  100. fn G(T:! I where .X = (I where .X = Constant)) {
  101. // TODO: The facet type T in G should match the facet type T in F.
  102. F(T);
  103. }
  104. }
  105. // --- fail_todo_named_constant_in_nested_facet_type_caller.carbon
  106. library "[[@TEST_NAME]]";
  107. interface I {
  108. let X:! type;
  109. let Y:! type;
  110. }
  111. fn Test() {
  112. // CHECK:STDERR: fail_todo_named_constant_in_nested_facet_type_caller.carbon:[[@LINE+4]]:7: error: semantics TODO: `local `let :!` bindings are currently unsupported` [SemanticsTodo]
  113. // CHECK:STDERR: let Constant:! type = ();
  114. // CHECK:STDERR: ^~~~~~~~~~~~~~~
  115. // CHECK:STDERR:
  116. let Constant:! type = ();
  117. fn F(T:! I where .X = (I where .X = ())) {}
  118. // TODO: The .Self reference in each .X should be different, there should be
  119. // no cycle here.
  120. fn G(T:! I where .X = (I where .X = Constant)) {
  121. // TODO: The facet type T in G should match the facet type T in F.
  122. F(T);
  123. }
  124. }
  125. // --- fail_named_constant_in_nested_facet_type_callee.carbon
  126. library "[[@TEST_NAME]]";
  127. interface I {
  128. let X:! type;
  129. let Y:! type;
  130. }
  131. fn Test() {
  132. // CHECK:STDERR: fail_named_constant_in_nested_facet_type_callee.carbon:[[@LINE+4]]:7: error: semantics TODO: `local `let :!` bindings are currently unsupported` [SemanticsTodo]
  133. // CHECK:STDERR: let Constant:! type = ();
  134. // CHECK:STDERR: ^~~~~~~~~~~~~~~
  135. // CHECK:STDERR:
  136. let Constant:! type = ();
  137. // TODO: The .Self reference in each .X should be different, there should be
  138. // no cycle here.
  139. fn F(T:! I where .X = (I where .X = Constant)) {}
  140. fn G(T:! I where .X = (I where .X = ())) {
  141. // TODO: The facet type T in G should match the facet type T in F.
  142. F(T);
  143. }
  144. }