fail_todo_no_params.carbon 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  6. // EXTRA-ARGS: --no-prelude-import --dump-sem-ir-ranges=if-present
  7. //
  8. // AUTOUPDATE
  9. // TIP: To test this file alone, run:
  10. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/function/declaration/fail_todo_no_params.carbon
  11. // TIP: To dump output, run:
  12. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/declaration/fail_todo_no_params.carbon
  13. // --- fail_no_body.carbon
  14. library "[[@TEST_NAME]]";
  15. // CHECK:STDERR: fail_no_body.carbon:[[@LINE+4]]:1: error: semantics TODO: `function with positional parameters` [SemanticsTodo]
  16. // CHECK:STDERR: fn A;
  17. // CHECK:STDERR: ^~~~~
  18. // CHECK:STDERR:
  19. fn A;
  20. // --- fail_todo_brace_body.carbon
  21. library "[[@TEST_NAME]]";
  22. // CHECK:STDERR: fail_todo_brace_body.carbon:[[@LINE+4]]:1: error: semantics TODO: `function with positional parameters` [SemanticsTodo]
  23. // CHECK:STDERR: fn A {
  24. // CHECK:STDERR: ^~~~~~
  25. // CHECK:STDERR:
  26. fn A {
  27. }
  28. // --- fail_todo_return_type.carbon
  29. library "[[@TEST_NAME]]";
  30. // CHECK:STDERR: fail_todo_return_type.carbon:[[@LINE+4]]:1: error: semantics TODO: `function with positional parameters` [SemanticsTodo]
  31. // CHECK:STDERR: fn A -> ();
  32. // CHECK:STDERR: ^~~~~~~~~~~
  33. // CHECK:STDERR:
  34. fn A -> ();
  35. // --- fail_todo_implicit_only.carbon
  36. library "[[@TEST_NAME]]";
  37. // CHECK:STDERR: fail_todo_implicit_only.carbon:[[@LINE+4]]:1: error: semantics TODO: `function with positional parameters` [SemanticsTodo]
  38. // CHECK:STDERR: fn A[] -> ();
  39. // CHECK:STDERR: ^~~~~~~~~~~~~
  40. // CHECK:STDERR:
  41. fn A[] -> ();
  42. // --- fail_todo_arrow_body.carbon
  43. // TODO: We don't have parsing support for this yet.
  44. library "[[@TEST_NAME]]";
  45. // CHECK:STDERR: fail_todo_arrow_body.carbon:[[@LINE+8]]:6: error: `fn` declarations must either end with a `;` or have a `{ ... }` block for a definition [ExpectedDeclSemiOrDefinition]
  46. // CHECK:STDERR: fn A => 0;
  47. // CHECK:STDERR: ^~
  48. // CHECK:STDERR:
  49. // CHECK:STDERR: fail_todo_arrow_body.carbon:[[@LINE+4]]:1: error: semantics TODO: `handle invalid parse trees in `check`` [SemanticsTodo]
  50. // CHECK:STDERR: fn A => 0;
  51. // CHECK:STDERR: ^~~~~~~~~~
  52. // CHECK:STDERR:
  53. fn A => 0;
  54. // --- fail_invalid_file_generic_regression_test.carbon
  55. library "[[@TEST_NAME]]";
  56. // CHECK:STDERR: fail_invalid_file_generic_regression_test.carbon:[[@LINE+8]]:5: error: semantics TODO: `handle invalid parse trees in `check`` [SemanticsTodo]
  57. // CHECK:STDERR: var x:! () = ();
  58. // CHECK:STDERR: ^~~~~~
  59. // CHECK:STDERR:
  60. // CHECK:STDERR: fail_invalid_file_generic_regression_test.carbon:[[@LINE+4]]:12: error: `var` pattern cannot declare a compile-time binding [CompileTimeBindingInVarDecl]
  61. // CHECK:STDERR: var x:! () = ();
  62. // CHECK:STDERR: ^
  63. // CHECK:STDERR:
  64. var x:! () = ();
  65. fn A {
  66. A();
  67. }
  68. // CHECK:STDOUT: --- fail_no_body.carbon
  69. // CHECK:STDOUT:
  70. // CHECK:STDOUT: constants {
  71. // CHECK:STDOUT: %A.type: type = fn_type @A [concrete]
  72. // CHECK:STDOUT: %A: %A.type = struct_value () [concrete]
  73. // CHECK:STDOUT: }
  74. // CHECK:STDOUT:
  75. // CHECK:STDOUT: file {
  76. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  77. // CHECK:STDOUT: .A = %A.decl
  78. // CHECK:STDOUT: }
  79. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [concrete = constants.%A] {} {}
  80. // CHECK:STDOUT: }
  81. // CHECK:STDOUT:
  82. // CHECK:STDOUT: fn @A;
  83. // CHECK:STDOUT:
  84. // CHECK:STDOUT: --- fail_todo_brace_body.carbon
  85. // CHECK:STDOUT:
  86. // CHECK:STDOUT: constants {
  87. // CHECK:STDOUT: %A.type: type = fn_type @A [concrete]
  88. // CHECK:STDOUT: %A: %A.type = struct_value () [concrete]
  89. // CHECK:STDOUT: }
  90. // CHECK:STDOUT:
  91. // CHECK:STDOUT: file {
  92. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  93. // CHECK:STDOUT: .A = %A.decl
  94. // CHECK:STDOUT: }
  95. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [concrete = constants.%A] {} {}
  96. // CHECK:STDOUT: }
  97. // CHECK:STDOUT:
  98. // CHECK:STDOUT: fn @A {
  99. // CHECK:STDOUT: !entry:
  100. // CHECK:STDOUT: return
  101. // CHECK:STDOUT: }
  102. // CHECK:STDOUT:
  103. // CHECK:STDOUT: --- fail_todo_return_type.carbon
  104. // CHECK:STDOUT:
  105. // CHECK:STDOUT: constants {
  106. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  107. // CHECK:STDOUT: %pattern_type: type = pattern_type %empty_tuple.type [concrete]
  108. // CHECK:STDOUT: %A.type: type = fn_type @A [concrete]
  109. // CHECK:STDOUT: %A: %A.type = struct_value () [concrete]
  110. // CHECK:STDOUT: }
  111. // CHECK:STDOUT:
  112. // CHECK:STDOUT: file {
  113. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  114. // CHECK:STDOUT: .A = %A.decl
  115. // CHECK:STDOUT: }
  116. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [concrete = constants.%A] {
  117. // CHECK:STDOUT: %return.patt: %pattern_type = return_slot_pattern [concrete]
  118. // CHECK:STDOUT: %return.param_patt: %pattern_type = out_param_pattern %return.patt, call_param0 [concrete]
  119. // CHECK:STDOUT: } {
  120. // CHECK:STDOUT: %.loc7_10.1: %empty_tuple.type = tuple_literal ()
  121. // CHECK:STDOUT: %.loc7_10.2: type = converted %.loc7_10.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  122. // CHECK:STDOUT: %return.param: ref %empty_tuple.type = out_param call_param0
  123. // CHECK:STDOUT: %return: ref %empty_tuple.type = return_slot %return.param
  124. // CHECK:STDOUT: }
  125. // CHECK:STDOUT: }
  126. // CHECK:STDOUT:
  127. // CHECK:STDOUT: fn @A() -> %empty_tuple.type;
  128. // CHECK:STDOUT:
  129. // CHECK:STDOUT: --- fail_todo_implicit_only.carbon
  130. // CHECK:STDOUT:
  131. // CHECK:STDOUT: constants {
  132. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  133. // CHECK:STDOUT: %pattern_type: type = pattern_type %empty_tuple.type [concrete]
  134. // CHECK:STDOUT: %A.type: type = fn_type @A [concrete]
  135. // CHECK:STDOUT: %A: %A.type = struct_value () [concrete]
  136. // CHECK:STDOUT: }
  137. // CHECK:STDOUT:
  138. // CHECK:STDOUT: file {
  139. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  140. // CHECK:STDOUT: .A = %A.decl
  141. // CHECK:STDOUT: }
  142. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [concrete = constants.%A] {
  143. // CHECK:STDOUT: %return.patt: %pattern_type = return_slot_pattern [concrete]
  144. // CHECK:STDOUT: %return.param_patt: %pattern_type = out_param_pattern %return.patt, call_param0 [concrete]
  145. // CHECK:STDOUT: } {
  146. // CHECK:STDOUT: %.loc7_12.1: %empty_tuple.type = tuple_literal ()
  147. // CHECK:STDOUT: %.loc7_12.2: type = converted %.loc7_12.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  148. // CHECK:STDOUT: %return.param: ref %empty_tuple.type = out_param call_param0
  149. // CHECK:STDOUT: %return: ref %empty_tuple.type = return_slot %return.param
  150. // CHECK:STDOUT: }
  151. // CHECK:STDOUT: }
  152. // CHECK:STDOUT:
  153. // CHECK:STDOUT: fn @A() -> %empty_tuple.type;
  154. // CHECK:STDOUT:
  155. // CHECK:STDOUT: --- fail_todo_arrow_body.carbon
  156. // CHECK:STDOUT:
  157. // CHECK:STDOUT: --- fail_invalid_file_generic_regression_test.carbon
  158. // CHECK:STDOUT:
  159. // CHECK:STDOUT: constants {
  160. // CHECK:STDOUT: }
  161. // CHECK:STDOUT: