fail_not_facet.carbon 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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+3]]:8: error: name `e` not found [NameNotFound]
  27. // CHECK:STDERR: var v: e where .x = 3;
  28. // CHECK:STDERR: ^
  29. var v: e where .x = 3;
  30. // CHECK:STDOUT: --- fail_left_where_not_facet.carbon
  31. // CHECK:STDOUT:
  32. // CHECK:STDOUT: constants {
  33. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  34. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  35. // CHECK:STDOUT: %Bool.type: type = fn_type @Bool [template]
  36. // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template]
  37. // CHECK:STDOUT: %T.patt: <error> = symbolic_binding_pattern T, 0 [symbolic]
  38. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  39. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: imports {
  43. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  44. // CHECK:STDOUT: .Int = %import_ref.187
  45. // CHECK:STDOUT: .Bool = %import_ref.f7c
  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 [template] {
  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 [template = constants.%F] {
  58. // CHECK:STDOUT: %T.patt.loc8_6.1: <error> = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc8_6.2 (constants.%T.patt)]
  59. // CHECK:STDOUT: %T.param_patt: <error> = value_param_pattern %T.patt.loc8_6.1, runtime_param<invalid> [symbolic = %T.patt.loc8_6.2 (constants.%T.patt)]
  60. // CHECK:STDOUT: } {
  61. // CHECK:STDOUT: %T.param: <error> = value_param runtime_param<invalid>
  62. // CHECK:STDOUT: %.loc8_14.1: type = splice_block %.loc8_14.2 [template = <error>] {
  63. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  64. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  65. // CHECK:STDOUT: %.Self: <error> = bind_symbolic_name .Self [template = <error>]
  66. // CHECK:STDOUT: %.Self.ref: <error> = name_ref .Self, %.Self [template = <error>]
  67. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  68. // CHECK:STDOUT: %.loc8_14.2: type = where_expr %.Self [template = <error>] {
  69. // CHECK:STDOUT: requirement_equivalent %.Self.ref, %bool.make_type
  70. // CHECK:STDOUT: }
  71. // CHECK:STDOUT: }
  72. // CHECK:STDOUT: %T: <error> = bind_symbolic_name T, 0, %T.param [template = <error>]
  73. // CHECK:STDOUT: }
  74. // CHECK:STDOUT: }
  75. // CHECK:STDOUT:
  76. // CHECK:STDOUT: generic fn @F(%T: <error>) {
  77. // CHECK:STDOUT: %T.patt.loc8_6.2: <error> = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc8_6.2 (constants.%T.patt)]
  78. // CHECK:STDOUT:
  79. // CHECK:STDOUT: fn(%T.param_patt: <error>);
  80. // CHECK:STDOUT: }
  81. // CHECK:STDOUT:
  82. // CHECK:STDOUT: specific @F(<error>) {
  83. // CHECK:STDOUT: %T.patt.loc8_6.2 => <error>
  84. // CHECK:STDOUT: }
  85. // CHECK:STDOUT:
  86. // CHECK:STDOUT: --- fail_left_where_unknown.carbon
  87. // CHECK:STDOUT:
  88. // CHECK:STDOUT: constants {
  89. // CHECK:STDOUT: %Bool.type: type = fn_type @Bool [template]
  90. // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template]
  91. // CHECK:STDOUT: %U.patt: <error> = symbolic_binding_pattern U, 0 [symbolic]
  92. // CHECK:STDOUT: %G.type: type = fn_type @G [template]
  93. // CHECK:STDOUT: %G: %G.type = struct_value () [template]
  94. // CHECK:STDOUT: }
  95. // CHECK:STDOUT:
  96. // CHECK:STDOUT: imports {
  97. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  98. // CHECK:STDOUT: .Bool = %import_ref
  99. // CHECK:STDOUT: import Core//prelude
  100. // CHECK:STDOUT: import Core//prelude/...
  101. // CHECK:STDOUT: }
  102. // CHECK:STDOUT: }
  103. // CHECK:STDOUT:
  104. // CHECK:STDOUT: file {
  105. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  106. // CHECK:STDOUT: .Core = imports.%Core
  107. // CHECK:STDOUT: .G = %G.decl
  108. // CHECK:STDOUT: }
  109. // CHECK:STDOUT: %Core.import = import Core
  110. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {
  111. // CHECK:STDOUT: %U.patt.loc8_6.1: <error> = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc8_6.2 (constants.%U.patt)]
  112. // CHECK:STDOUT: %U.param_patt: <error> = value_param_pattern %U.patt.loc8_6.1, runtime_param<invalid> [symbolic = %U.patt.loc8_6.2 (constants.%U.patt)]
  113. // CHECK:STDOUT: } {
  114. // CHECK:STDOUT: %U.param: <error> = value_param runtime_param<invalid>
  115. // CHECK:STDOUT: %.loc8_23.1: type = splice_block %.loc8_23.2 [template = <error>] {
  116. // CHECK:STDOUT: %NOT_DECLARED.ref: <error> = name_ref NOT_DECLARED, <error> [template = <error>]
  117. // CHECK:STDOUT: %.Self: <error> = bind_symbolic_name .Self [template = <error>]
  118. // CHECK:STDOUT: %.Self.ref: <error> = name_ref .Self, %.Self [template = <error>]
  119. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  120. // CHECK:STDOUT: %.loc8_23.2: type = where_expr %.Self [template = <error>] {
  121. // CHECK:STDOUT: requirement_equivalent %.Self.ref, %bool.make_type
  122. // CHECK:STDOUT: }
  123. // CHECK:STDOUT: }
  124. // CHECK:STDOUT: %U: <error> = bind_symbolic_name U, 0, %U.param [template = <error>]
  125. // CHECK:STDOUT: }
  126. // CHECK:STDOUT: }
  127. // CHECK:STDOUT:
  128. // CHECK:STDOUT: generic fn @G(%U: <error>) {
  129. // CHECK:STDOUT: %U.patt.loc8_6.2: <error> = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc8_6.2 (constants.%U.patt)]
  130. // CHECK:STDOUT:
  131. // CHECK:STDOUT: fn(%U.param_patt: <error>);
  132. // CHECK:STDOUT: }
  133. // CHECK:STDOUT:
  134. // CHECK:STDOUT: specific @G(<error>) {
  135. // CHECK:STDOUT: %U.patt.loc8_6.2 => <error>
  136. // CHECK:STDOUT: }
  137. // CHECK:STDOUT:
  138. // CHECK:STDOUT: --- fail_var.carbon
  139. // CHECK:STDOUT:
  140. // CHECK:STDOUT: constants {
  141. // CHECK:STDOUT: }
  142. // CHECK:STDOUT:
  143. // CHECK:STDOUT: imports {
  144. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  145. // CHECK:STDOUT: import Core//prelude
  146. // CHECK:STDOUT: import Core//prelude/...
  147. // CHECK:STDOUT: }
  148. // CHECK:STDOUT: }
  149. // CHECK:STDOUT:
  150. // CHECK:STDOUT: file {
  151. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  152. // CHECK:STDOUT: .Core = imports.%Core
  153. // CHECK:STDOUT: .v = %v
  154. // CHECK:STDOUT: }
  155. // CHECK:STDOUT: %Core.import = import Core
  156. // CHECK:STDOUT: %v.var: ref <error> = var v
  157. // CHECK:STDOUT: %v: ref <error> = bind_name v, %v.var
  158. // CHECK:STDOUT: }
  159. // CHECK:STDOUT: