fail_assoc_const_not_binding.carbon 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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/none.carbon
  6. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  7. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  8. //
  9. // AUTOUPDATE
  10. // TIP: To test this file alone, run:
  11. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interface/fail_assoc_const_not_binding.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interface/fail_assoc_const_not_binding.carbon
  14. // --- fail_tuple_pattern.carbon
  15. library "[[@TEST_NAME]]";
  16. interface I {
  17. // CHECK:STDERR: fail_tuple_pattern.carbon:[[@LINE+4]]:7: error: found tuple pattern in associated constant declaration; expected symbolic binding pattern [ExpectedSingleBindingInAssociatedConstant]
  18. // CHECK:STDERR: let (T:! type, U:! type);
  19. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~
  20. // CHECK:STDERR:
  21. let (T:! type, U:! type);
  22. }
  23. // --- fail_tuple_pattern_with_default.carbon
  24. library "[[@TEST_NAME]]";
  25. interface I {
  26. // CHECK:STDERR: fail_tuple_pattern_with_default.carbon:[[@LINE+4]]:15: error: found tuple pattern in associated constant declaration; expected symbolic binding pattern [ExpectedSingleBindingInAssociatedConstant]
  27. // CHECK:STDERR: default let (T:! type, U:! type) = ({}, {});
  28. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~
  29. // CHECK:STDERR:
  30. default let (T:! type, U:! type) = ({}, {});
  31. }
  32. // --- fail_var_pattern.carbon
  33. library "[[@TEST_NAME]]";
  34. interface I {
  35. // CHECK:STDERR: fail_var_pattern.carbon:[[@LINE+8]]:11: error: semantics TODO: `handle invalid parse trees in `check`` [SemanticsTodo]
  36. // CHECK:STDERR: let var T:! type;
  37. // CHECK:STDERR: ^~~~~~~~
  38. // CHECK:STDERR:
  39. // CHECK:STDERR: fail_var_pattern.carbon:[[@LINE+4]]:19: error: `var` pattern cannot declare a compile-time binding [CompileTimeBindingInVarDecl]
  40. // CHECK:STDERR: let var T:! type;
  41. // CHECK:STDERR: ^
  42. // CHECK:STDERR:
  43. let var T:! type;
  44. }
  45. // --- fail_var_pattern_with_default.carbon
  46. library "[[@TEST_NAME]]";
  47. interface I {
  48. // CHECK:STDERR: fail_var_pattern_with_default.carbon:[[@LINE+8]]:19: error: semantics TODO: `handle invalid parse trees in `check`` [SemanticsTodo]
  49. // CHECK:STDERR: default let var T:! type = {};
  50. // CHECK:STDERR: ^~~~~~~~
  51. // CHECK:STDERR:
  52. // CHECK:STDERR: fail_var_pattern_with_default.carbon:[[@LINE+4]]:28: error: `var` pattern cannot declare a compile-time binding [CompileTimeBindingInVarDecl]
  53. // CHECK:STDERR: default let var T:! type = {};
  54. // CHECK:STDERR: ^
  55. // CHECK:STDERR:
  56. default let var T:! type = {};
  57. }
  58. // CHECK:STDOUT: --- fail_tuple_pattern.carbon
  59. // CHECK:STDOUT:
  60. // CHECK:STDOUT: constants {
  61. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  62. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic]
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT:
  65. // CHECK:STDOUT: file {
  66. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  67. // CHECK:STDOUT: .I = %I.decl
  68. // CHECK:STDOUT: }
  69. // CHECK:STDOUT: %I.decl: type = interface_decl @I [concrete = constants.%I.type] {} {}
  70. // CHECK:STDOUT: }
  71. // CHECK:STDOUT:
  72. // CHECK:STDOUT: interface @I {
  73. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  74. // CHECK:STDOUT:
  75. // CHECK:STDOUT: !members:
  76. // CHECK:STDOUT: .Self = %Self
  77. // CHECK:STDOUT: has_error
  78. // CHECK:STDOUT: witness = ()
  79. // CHECK:STDOUT: }
  80. // CHECK:STDOUT:
  81. // CHECK:STDOUT: assoc_const @T T:! type;
  82. // CHECK:STDOUT:
  83. // CHECK:STDOUT: assoc_const @U U:! type;
  84. // CHECK:STDOUT:
  85. // CHECK:STDOUT: --- fail_tuple_pattern_with_default.carbon
  86. // CHECK:STDOUT:
  87. // CHECK:STDOUT: constants {
  88. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  89. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic]
  90. // CHECK:STDOUT: }
  91. // CHECK:STDOUT:
  92. // CHECK:STDOUT: file {
  93. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  94. // CHECK:STDOUT: .I = %I.decl
  95. // CHECK:STDOUT: }
  96. // CHECK:STDOUT: %I.decl: type = interface_decl @I [concrete = constants.%I.type] {} {}
  97. // CHECK:STDOUT: }
  98. // CHECK:STDOUT:
  99. // CHECK:STDOUT: interface @I {
  100. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  101. // CHECK:STDOUT:
  102. // CHECK:STDOUT: !members:
  103. // CHECK:STDOUT: .Self = %Self
  104. // CHECK:STDOUT: has_error
  105. // CHECK:STDOUT: witness = ()
  106. // CHECK:STDOUT: }
  107. // CHECK:STDOUT:
  108. // CHECK:STDOUT: assoc_const @T T:! type;
  109. // CHECK:STDOUT:
  110. // CHECK:STDOUT: assoc_const @U U:! type;
  111. // CHECK:STDOUT:
  112. // CHECK:STDOUT: --- fail_var_pattern.carbon
  113. // CHECK:STDOUT:
  114. // CHECK:STDOUT: constants {
  115. // CHECK:STDOUT: }
  116. // CHECK:STDOUT:
  117. // CHECK:STDOUT: interface @I {
  118. // CHECK:STDOUT: !members:
  119. // CHECK:STDOUT: .Self = <unexpected>.inst17
  120. // CHECK:STDOUT: witness = invalid
  121. // CHECK:STDOUT: }
  122. // CHECK:STDOUT:
  123. // CHECK:STDOUT: --- fail_var_pattern_with_default.carbon
  124. // CHECK:STDOUT:
  125. // CHECK:STDOUT: constants {
  126. // CHECK:STDOUT: }
  127. // CHECK:STDOUT:
  128. // CHECK:STDOUT: interface @I {
  129. // CHECK:STDOUT: !members:
  130. // CHECK:STDOUT: .Self = <unexpected>.inst17
  131. // CHECK:STDOUT: witness = invalid
  132. // CHECK:STDOUT: }
  133. // CHECK:STDOUT: