fail_not_facet.carbon 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/where_expr/fail_not_facet.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/where_expr/fail_not_facet.carbon
  10. // --- fail_left_where_not_facet.carbon
  11. library "[[@TEST_NAME]]";
  12. // CHECK:STDERR: fail_left_where_not_facet.carbon:[[@LINE+4]]:10: error: left argument of `where` operator must be a facet type [WhereOnNonFacetType]
  13. // CHECK:STDERR: fn F(T:! i32 where .Self == bool);
  14. // CHECK:STDERR: ^~~
  15. // CHECK:STDERR:
  16. fn F(T:! i32 where .Self == bool);
  17. // --- fail_left_where_unknown.carbon
  18. library "[[@TEST_NAME]]";
  19. // CHECK:STDERR: fail_left_where_unknown.carbon:[[@LINE+4]]:10: error: name `NOT_DECLARED` not found [NameNotFound]
  20. // CHECK:STDERR: fn G(U:! NOT_DECLARED where .Self == bool);
  21. // CHECK:STDERR: ^~~~~~~~~~~~
  22. // CHECK:STDERR:
  23. fn G(U:! NOT_DECLARED where .Self == bool);
  24. // --- fail_var.carbon
  25. library "[[@TEST_NAME]]";
  26. // CHECK:STDERR: fail_var.carbon:[[@LINE+4]]:8: error: name `e` not found [NameNotFound]
  27. // CHECK:STDERR: var v: e where .x = 3;
  28. // CHECK:STDERR: ^
  29. // CHECK:STDERR:
  30. var v: e where .x = 3;
  31. // CHECK:STDOUT: --- fail_left_where_not_facet.carbon
  32. // CHECK:STDOUT:
  33. // CHECK:STDOUT: constants {
  34. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  35. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  36. // CHECK:STDOUT: %Bool.type: type = fn_type @Bool [concrete]
  37. // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [concrete]
  38. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  39. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: imports {
  43. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  44. // CHECK:STDOUT: .Int = %Core.Int
  45. // CHECK:STDOUT: .Bool = %Core.Bool
  46. // CHECK:STDOUT: import Core//prelude
  47. // CHECK:STDOUT: import Core//prelude/...
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT:
  51. // CHECK:STDOUT: file {
  52. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  53. // CHECK:STDOUT: .Core = imports.%Core
  54. // CHECK:STDOUT: .F = %F.decl
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT: %Core.import = import Core
  57. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  58. // CHECK:STDOUT: %T.patt: <error> = symbolic_binding_pattern T, 0 [concrete = <error>]
  59. // CHECK:STDOUT: } {
  60. // CHECK:STDOUT: %.loc8_14.1: type = splice_block %.loc8_14.2 [concrete = <error>] {
  61. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  62. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  63. // CHECK:STDOUT: %.Self: <error> = bind_symbolic_name .Self [concrete = <error>]
  64. // CHECK:STDOUT: %.Self.ref: <error> = name_ref .Self, %.Self [concrete = <error>]
  65. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [concrete = bool]
  66. // CHECK:STDOUT: %.loc8_14.2: type = where_expr %.Self [concrete = <error>] {
  67. // CHECK:STDOUT: requirement_equivalent %.Self.ref, %bool.make_type
  68. // CHECK:STDOUT: }
  69. // CHECK:STDOUT: }
  70. // CHECK:STDOUT: %T: <error> = bind_symbolic_name T, 0 [concrete = <error>]
  71. // CHECK:STDOUT: }
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT:
  74. // CHECK:STDOUT: generic fn @F(%T: <error>) {
  75. // CHECK:STDOUT: fn(%T.patt: <error>);
  76. // CHECK:STDOUT: }
  77. // CHECK:STDOUT:
  78. // CHECK:STDOUT: specific @F(<error>) {}
  79. // CHECK:STDOUT:
  80. // CHECK:STDOUT: --- fail_left_where_unknown.carbon
  81. // CHECK:STDOUT:
  82. // CHECK:STDOUT: constants {
  83. // CHECK:STDOUT: %Bool.type: type = fn_type @Bool [concrete]
  84. // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [concrete]
  85. // CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
  86. // CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
  87. // CHECK:STDOUT: }
  88. // CHECK:STDOUT:
  89. // CHECK:STDOUT: imports {
  90. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  91. // CHECK:STDOUT: .Bool = %Core.Bool
  92. // CHECK:STDOUT: import Core//prelude
  93. // CHECK:STDOUT: import Core//prelude/...
  94. // CHECK:STDOUT: }
  95. // CHECK:STDOUT: }
  96. // CHECK:STDOUT:
  97. // CHECK:STDOUT: file {
  98. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  99. // CHECK:STDOUT: .Core = imports.%Core
  100. // CHECK:STDOUT: .NOT_DECLARED = <poisoned>
  101. // CHECK:STDOUT: .G = %G.decl
  102. // CHECK:STDOUT: }
  103. // CHECK:STDOUT: %Core.import = import Core
  104. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {
  105. // CHECK:STDOUT: %U.patt: <error> = symbolic_binding_pattern U, 0 [concrete = <error>]
  106. // CHECK:STDOUT: } {
  107. // CHECK:STDOUT: %.loc8_23.1: type = splice_block %.loc8_23.2 [concrete = <error>] {
  108. // CHECK:STDOUT: %NOT_DECLARED.ref: <error> = name_ref NOT_DECLARED, <error> [concrete = <error>]
  109. // CHECK:STDOUT: %.Self: <error> = bind_symbolic_name .Self [concrete = <error>]
  110. // CHECK:STDOUT: %.Self.ref: <error> = name_ref .Self, %.Self [concrete = <error>]
  111. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [concrete = bool]
  112. // CHECK:STDOUT: %.loc8_23.2: type = where_expr %.Self [concrete = <error>] {
  113. // CHECK:STDOUT: requirement_equivalent %.Self.ref, %bool.make_type
  114. // CHECK:STDOUT: }
  115. // CHECK:STDOUT: }
  116. // CHECK:STDOUT: %U: <error> = bind_symbolic_name U, 0 [concrete = <error>]
  117. // CHECK:STDOUT: }
  118. // CHECK:STDOUT: }
  119. // CHECK:STDOUT:
  120. // CHECK:STDOUT: generic fn @G(%U: <error>) {
  121. // CHECK:STDOUT: fn(%U.patt: <error>);
  122. // CHECK:STDOUT: }
  123. // CHECK:STDOUT:
  124. // CHECK:STDOUT: specific @G(<error>) {}
  125. // CHECK:STDOUT:
  126. // CHECK:STDOUT: --- fail_var.carbon
  127. // CHECK:STDOUT:
  128. // CHECK:STDOUT: constants {
  129. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete]
  130. // CHECK:STDOUT: }
  131. // CHECK:STDOUT:
  132. // CHECK:STDOUT: imports {
  133. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  134. // CHECK:STDOUT: import Core//prelude
  135. // CHECK:STDOUT: import Core//prelude/...
  136. // CHECK:STDOUT: }
  137. // CHECK:STDOUT: }
  138. // CHECK:STDOUT:
  139. // CHECK:STDOUT: file {
  140. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  141. // CHECK:STDOUT: .Core = imports.%Core
  142. // CHECK:STDOUT: .e = <poisoned>
  143. // CHECK:STDOUT: .v = %v
  144. // CHECK:STDOUT: }
  145. // CHECK:STDOUT: %Core.import = import Core
  146. // CHECK:STDOUT: name_binding_decl {
  147. // CHECK:STDOUT: %v.patt: <error> = binding_pattern v
  148. // CHECK:STDOUT: %.loc8_1: <error> = var_pattern %v.patt
  149. // CHECK:STDOUT: }
  150. // CHECK:STDOUT: %v.var: ref <error> = var v
  151. // CHECK:STDOUT: %.loc8_10.1: type = splice_block %.loc8_10.2 [concrete = <error>] {
  152. // CHECK:STDOUT: %e.ref: <error> = name_ref e, <error> [concrete = <error>]
  153. // CHECK:STDOUT: %.Self: <error> = bind_symbolic_name .Self [concrete = <error>]
  154. // CHECK:STDOUT: %.Self.ref: <error> = name_ref .Self, %.Self [concrete = <error>]
  155. // CHECK:STDOUT: %x.ref: <error> = name_ref x, <error> [concrete = <error>]
  156. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3]
  157. // CHECK:STDOUT: %.loc8_10.2: type = where_expr %.Self [concrete = <error>] {
  158. // CHECK:STDOUT: requirement_rewrite %x.ref, <error>
  159. // CHECK:STDOUT: }
  160. // CHECK:STDOUT: }
  161. // CHECK:STDOUT: %v: <error> = bind_name v, <error>
  162. // CHECK:STDOUT: }
  163. // CHECK:STDOUT: