fail_not_facet.carbon 4.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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+3]]:10: error: left argument of `where` operator must be a facet type
  13. // CHECK:STDERR: fn F(T:! i32 where .Self == bool);
  14. // CHECK:STDERR: ^~~
  15. fn F(T:! i32 where .Self == bool);
  16. // CHECK:STDOUT: --- fail_left_where_not_facet.carbon
  17. // CHECK:STDOUT:
  18. // CHECK:STDOUT: constants {
  19. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  20. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  21. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  22. // CHECK:STDOUT: %.Self: <error> = bind_symbolic_name .Self, 0 [symbolic]
  23. // CHECK:STDOUT: %Bool.type: type = fn_type @Bool [template]
  24. // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template]
  25. // CHECK:STDOUT: %T: <error> = bind_symbolic_name T, 0 [symbolic]
  26. // CHECK:STDOUT: %T.patt: <error> = symbolic_binding_pattern T, 0 [symbolic]
  27. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  28. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  29. // CHECK:STDOUT: }
  30. // CHECK:STDOUT:
  31. // CHECK:STDOUT: imports {
  32. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  33. // CHECK:STDOUT: .Int32 = %import_ref.1
  34. // CHECK:STDOUT: .Bool = %import_ref.2
  35. // CHECK:STDOUT: import Core//prelude
  36. // CHECK:STDOUT: import Core//prelude/operators
  37. // CHECK:STDOUT: import Core//prelude/types
  38. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  39. // CHECK:STDOUT: import Core//prelude/operators/as
  40. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  41. // CHECK:STDOUT: import Core//prelude/operators/comparison
  42. // CHECK:STDOUT: import Core//prelude/types/bool
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+9, loaded [template = constants.%Int32]
  45. // CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool]
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT:
  48. // CHECK:STDOUT: file {
  49. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  50. // CHECK:STDOUT: .Core = imports.%Core
  51. // CHECK:STDOUT: .F = %F.decl
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT: %Core.import = import Core
  54. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  55. // CHECK:STDOUT: %T.patt.loc7_6.1: <error> = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc7_6.2 (constants.%T.patt)]
  56. // CHECK:STDOUT: %T.param_patt: <error> = param_pattern %T.patt.loc7_6.1, runtime_param<invalid> [symbolic = %T.patt.loc7_6.2 (constants.%T.patt)]
  57. // CHECK:STDOUT: } {
  58. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  59. // CHECK:STDOUT: %.loc7_10.1: type = value_of_initializer %int.make_type_32 [template = i32]
  60. // CHECK:STDOUT: %.loc7_10.2: type = converted %int.make_type_32, %.loc7_10.1 [template = i32]
  61. // CHECK:STDOUT: %.Self: <error> = bind_symbolic_name .Self, 0 [symbolic = constants.%.Self]
  62. // CHECK:STDOUT: %.Self.ref: <error> = name_ref .Self, %.Self [symbolic = constants.%.Self]
  63. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  64. // CHECK:STDOUT: %.loc7_14: type = where_expr %.Self [template = <error>] {
  65. // CHECK:STDOUT: requirement_equivalent %.Self.ref, %bool.make_type
  66. // CHECK:STDOUT: }
  67. // CHECK:STDOUT: %param: <error> = param runtime_param<invalid>
  68. // CHECK:STDOUT: %T.loc7_6.1: <error> = bind_symbolic_name T, 0, %param [symbolic = %T.loc7_6.2 (constants.%T)]
  69. // CHECK:STDOUT: }
  70. // CHECK:STDOUT: }
  71. // CHECK:STDOUT:
  72. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  73. // CHECK:STDOUT:
  74. // CHECK:STDOUT: fn @Bool() -> type = "bool.make_type";
  75. // CHECK:STDOUT:
  76. // CHECK:STDOUT: generic fn @F(%T.loc7_6.1: <error>) {
  77. // CHECK:STDOUT: %T.loc7_6.2: <error> = bind_symbolic_name T, 0 [symbolic = %T.loc7_6.2 (constants.%T)]
  78. // CHECK:STDOUT: %T.patt.loc7_6.2: <error> = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc7_6.2 (constants.%T.patt)]
  79. // CHECK:STDOUT:
  80. // CHECK:STDOUT: fn(%T.param_patt: <error>);
  81. // CHECK:STDOUT: }
  82. // CHECK:STDOUT:
  83. // CHECK:STDOUT: specific @F(constants.%T) {
  84. // CHECK:STDOUT: %T.loc7_6.2 => constants.%T
  85. // CHECK:STDOUT: %T.patt.loc7_6.2 => constants.%T
  86. // CHECK:STDOUT: }
  87. // CHECK:STDOUT: