fail_designator.carbon 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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/no_prelude/fail_designator.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/where_expr/no_prelude/fail_designator.carbon
  10. // --- fail_designator_matches_var.carbon
  11. library "[[@TEST_NAME]]";
  12. fn Foo() -> () {
  13. var x: ();
  14. // CHECK:STDERR: fail_designator_matches_var.carbon:[[@LINE+4]]:10: error: semantics TODO: `HandleDesignatorExpr`
  15. // CHECK:STDERR: return .x;
  16. // CHECK:STDERR: ^~
  17. // CHECK:STDERR:
  18. return .x;
  19. }
  20. // --- fail_unknown_designator.carbon
  21. library "[[@TEST_NAME]]";
  22. fn Bar() -> () {
  23. // CHECK:STDERR: fail_unknown_designator.carbon:[[@LINE+4]]:10: error: semantics TODO: `HandleDesignatorExpr`
  24. // CHECK:STDERR: return .undef;
  25. // CHECK:STDERR: ^~~~~~
  26. // CHECK:STDERR:
  27. return .undef;
  28. }
  29. // --- fail_dot_self_method_return_value.carbon
  30. library "[[@TEST_NAME]]";
  31. class C {
  32. // CHECK:STDERR: fail_dot_self_method_return_value.carbon:[[@LINE+4]]:28: error: semantics TODO: `HandleSelfTypeName`
  33. // CHECK:STDERR: fn F() -> Self { return .Self; }
  34. // CHECK:STDERR: ^~~~
  35. // CHECK:STDERR:
  36. fn F() -> Self { return .Self; }
  37. }
  38. // --- fail_dot_self_method_return_type.carbon
  39. library "[[@TEST_NAME]]";
  40. class D {
  41. // CHECK:STDERR: fail_dot_self_method_return_type.carbon:[[@LINE+3]]:14: error: semantics TODO: `HandleSelfTypeName`
  42. // CHECK:STDERR: fn G() -> .Self { return Self; }
  43. // CHECK:STDERR: ^~~~
  44. fn G() -> .Self { return Self; }
  45. }
  46. // CHECK:STDOUT: --- fail_designator_matches_var.carbon
  47. // CHECK:STDOUT:
  48. // CHECK:STDOUT: constants {
  49. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  50. // CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template]
  51. // CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template]
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT:
  54. // CHECK:STDOUT: file {}
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: fn @Foo() -> %.1 {
  57. // CHECK:STDOUT: !entry:
  58. // CHECK:STDOUT: }
  59. // CHECK:STDOUT:
  60. // CHECK:STDOUT: --- fail_unknown_designator.carbon
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: constants {
  63. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  64. // CHECK:STDOUT: %Bar.type: type = fn_type @Bar [template]
  65. // CHECK:STDOUT: %Bar: %Bar.type = struct_value () [template]
  66. // CHECK:STDOUT: }
  67. // CHECK:STDOUT:
  68. // CHECK:STDOUT: file {}
  69. // CHECK:STDOUT:
  70. // CHECK:STDOUT: fn @Bar() -> %.1 {
  71. // CHECK:STDOUT: !entry:
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT:
  74. // CHECK:STDOUT: --- fail_dot_self_method_return_value.carbon
  75. // CHECK:STDOUT:
  76. // CHECK:STDOUT: constants {
  77. // CHECK:STDOUT: %C: type = class_type @C [template]
  78. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  79. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  80. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  81. // CHECK:STDOUT: %.2: type = struct_type {} [template]
  82. // CHECK:STDOUT: %.3: <witness> = complete_type_witness %.2 [template]
  83. // CHECK:STDOUT: %.4: type = ptr_type %.2 [template]
  84. // CHECK:STDOUT: }
  85. // CHECK:STDOUT:
  86. // CHECK:STDOUT: file {}
  87. // CHECK:STDOUT:
  88. // CHECK:STDOUT: class @C {
  89. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  90. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [template = constants.%C]
  91. // CHECK:STDOUT: %return.var: ref %C = var <return slot>
  92. // CHECK:STDOUT: }
  93. // CHECK:STDOUT: %.loc10: <witness> = complete_type_witness %.2 [template = constants.%.3]
  94. // CHECK:STDOUT:
  95. // CHECK:STDOUT: !members:
  96. // CHECK:STDOUT: .Self = constants.%C
  97. // CHECK:STDOUT: .F = %F.decl
  98. // CHECK:STDOUT: }
  99. // CHECK:STDOUT:
  100. // CHECK:STDOUT: fn @F() -> @C.%return.var: %C {
  101. // CHECK:STDOUT: !entry:
  102. // CHECK:STDOUT: }
  103. // CHECK:STDOUT:
  104. // CHECK:STDOUT: --- fail_dot_self_method_return_type.carbon
  105. // CHECK:STDOUT:
  106. // CHECK:STDOUT: constants {
  107. // CHECK:STDOUT: %D: type = class_type @D [template]
  108. // CHECK:STDOUT: }
  109. // CHECK:STDOUT:
  110. // CHECK:STDOUT: file {}
  111. // CHECK:STDOUT:
  112. // CHECK:STDOUT: class @D {
  113. // CHECK:STDOUT: !members:
  114. // CHECK:STDOUT: .Self = constants.%D
  115. // CHECK:STDOUT: }
  116. // CHECK:STDOUT: