fail_todo_control_flow_init.carbon 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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/var/fail_todo_control_flow_init.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/var/fail_todo_control_flow_init.carbon
  10. // CHECK:STDERR: fail_todo_control_flow_init.carbon:[[@LINE+16]]:13: error: semantics TODO: `Control flow expressions are currently only supported inside functions.` [SemanticsTodo]
  11. // CHECK:STDERR: var x: () = if true then () else ();
  12. // CHECK:STDERR: ^~~~~~~
  13. // CHECK:STDERR:
  14. // CHECK:STDERR: fail_todo_control_flow_init.carbon:[[@LINE+12]]:21: error: semantics TODO: `Control flow expressions are currently only supported inside functions.` [SemanticsTodo]
  15. // CHECK:STDERR: var x: () = if true then () else ();
  16. // CHECK:STDERR: ^~~~~~~
  17. // CHECK:STDERR:
  18. // CHECK:STDERR: fail_todo_control_flow_init.carbon:[[@LINE+8]]:13: error: semantics TODO: `Control flow expressions are currently only supported inside functions.` [SemanticsTodo]
  19. // CHECK:STDERR: var x: () = if true then () else ();
  20. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~
  21. // CHECK:STDERR:
  22. // CHECK:STDERR: fail_todo_control_flow_init.carbon:[[@LINE+4]]:13: error: semantics TODO: `Control flow expressions are currently only supported inside functions.` [SemanticsTodo]
  23. // CHECK:STDERR: var x: () = if true then () else ();
  24. // CHECK:STDERR: ^~~~~~~
  25. // CHECK:STDERR:
  26. var x: () = if true then () else ();
  27. // CHECK:STDERR: fail_todo_control_flow_init.carbon:[[@LINE+16]]:14: error: semantics TODO: `Control flow expressions are currently only supported inside functions.` [SemanticsTodo]
  28. // CHECK:STDERR: var x2: () = if false then () else ();
  29. // CHECK:STDERR: ^~~~~~~~
  30. // CHECK:STDERR:
  31. // CHECK:STDERR: fail_todo_control_flow_init.carbon:[[@LINE+12]]:23: error: semantics TODO: `Control flow expressions are currently only supported inside functions.` [SemanticsTodo]
  32. // CHECK:STDERR: var x2: () = if false then () else ();
  33. // CHECK:STDERR: ^~~~~~~
  34. // CHECK:STDERR:
  35. // CHECK:STDERR: fail_todo_control_flow_init.carbon:[[@LINE+8]]:14: error: semantics TODO: `Control flow expressions are currently only supported inside functions.` [SemanticsTodo]
  36. // CHECK:STDERR: var x2: () = if false then () else ();
  37. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~
  38. // CHECK:STDERR:
  39. // CHECK:STDERR: fail_todo_control_flow_init.carbon:[[@LINE+4]]:14: error: semantics TODO: `Control flow expressions are currently only supported inside functions.` [SemanticsTodo]
  40. // CHECK:STDERR: var x2: () = if false then () else ();
  41. // CHECK:STDERR: ^~~~~~~~
  42. // CHECK:STDERR:
  43. var x2: () = if false then () else ();
  44. // CHECK:STDERR: fail_todo_control_flow_init.carbon:[[@LINE+12]]:15: error: semantics TODO: `Control flow expressions are currently only supported inside functions.` [SemanticsTodo]
  45. // CHECK:STDERR: var y: bool = true or false;
  46. // CHECK:STDERR: ^~~~~~~
  47. // CHECK:STDERR:
  48. // CHECK:STDERR: fail_todo_control_flow_init.carbon:[[@LINE+8]]:15: error: semantics TODO: `Control flow expressions are currently only supported inside functions.` [SemanticsTodo]
  49. // CHECK:STDERR: var y: bool = true or false;
  50. // CHECK:STDERR: ^~~~~~~~~~~~~
  51. // CHECK:STDERR:
  52. // CHECK:STDERR: fail_todo_control_flow_init.carbon:[[@LINE+4]]:15: error: semantics TODO: `Control flow expressions are currently only supported inside functions.` [SemanticsTodo]
  53. // CHECK:STDERR: var y: bool = true or false;
  54. // CHECK:STDERR: ^~~~~~~~~~~~~
  55. // CHECK:STDERR:
  56. var y: bool = true or false;
  57. // CHECK:STDERR: fail_todo_control_flow_init.carbon:[[@LINE+12]]:16: error: semantics TODO: `Control flow expressions are currently only supported inside functions.` [SemanticsTodo]
  58. // CHECK:STDERR: var y2: bool = false or true;
  59. // CHECK:STDERR: ^~~~~~~~
  60. // CHECK:STDERR:
  61. // CHECK:STDERR: fail_todo_control_flow_init.carbon:[[@LINE+8]]:16: error: semantics TODO: `Control flow expressions are currently only supported inside functions.` [SemanticsTodo]
  62. // CHECK:STDERR: var y2: bool = false or true;
  63. // CHECK:STDERR: ^~~~~~~~~~~~~
  64. // CHECK:STDERR:
  65. // CHECK:STDERR: fail_todo_control_flow_init.carbon:[[@LINE+4]]:16: error: semantics TODO: `Control flow expressions are currently only supported inside functions.` [SemanticsTodo]
  66. // CHECK:STDERR: var y2: bool = false or true;
  67. // CHECK:STDERR: ^~~~~~~~~~~~~
  68. // CHECK:STDERR:
  69. var y2: bool = false or true;
  70. // CHECK:STDOUT: --- fail_todo_control_flow_init.carbon
  71. // CHECK:STDOUT:
  72. // CHECK:STDOUT: constants {
  73. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  74. // CHECK:STDOUT: %true: bool = bool_literal true [template]
  75. // CHECK:STDOUT: %Bool.type: type = fn_type @Bool [template]
  76. // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template]
  77. // CHECK:STDOUT: }
  78. // CHECK:STDOUT:
  79. // CHECK:STDOUT: imports {
  80. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  81. // CHECK:STDOUT: .Bool = %Core.Bool
  82. // CHECK:STDOUT: import Core//prelude
  83. // CHECK:STDOUT: import Core//prelude/...
  84. // CHECK:STDOUT: }
  85. // CHECK:STDOUT: }
  86. // CHECK:STDOUT:
  87. // CHECK:STDOUT: file {
  88. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  89. // CHECK:STDOUT: .Core = imports.%Core
  90. // CHECK:STDOUT: .x = %x
  91. // CHECK:STDOUT: .x2 = %x2
  92. // CHECK:STDOUT: .y = %y
  93. // CHECK:STDOUT: .y2 = %y2
  94. // CHECK:STDOUT: }
  95. // CHECK:STDOUT: %Core.import = import Core
  96. // CHECK:STDOUT: name_binding_decl {
  97. // CHECK:STDOUT: %x.patt: %empty_tuple.type = binding_pattern x
  98. // CHECK:STDOUT: %.loc27_1: %empty_tuple.type = var_pattern %x.patt
  99. // CHECK:STDOUT: }
  100. // CHECK:STDOUT: %x.var: ref %empty_tuple.type = var x
  101. // CHECK:STDOUT: %.loc27_9.1: type = splice_block %.loc27_9.3 [template = constants.%empty_tuple.type] {
  102. // CHECK:STDOUT: %.loc27_9.2: %empty_tuple.type = tuple_literal ()
  103. // CHECK:STDOUT: %.loc27_9.3: type = converted %.loc27_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  104. // CHECK:STDOUT: }
  105. // CHECK:STDOUT: %x: ref %empty_tuple.type = bind_name x, %x.var
  106. // CHECK:STDOUT: name_binding_decl {
  107. // CHECK:STDOUT: %x2.patt: %empty_tuple.type = binding_pattern x2
  108. // CHECK:STDOUT: %.loc45_1: %empty_tuple.type = var_pattern %x2.patt
  109. // CHECK:STDOUT: }
  110. // CHECK:STDOUT: %x2.var: ref %empty_tuple.type = var x2
  111. // CHECK:STDOUT: %.loc45_10.1: type = splice_block %.loc45_10.3 [template = constants.%empty_tuple.type] {
  112. // CHECK:STDOUT: %.loc45_10.2: %empty_tuple.type = tuple_literal ()
  113. // CHECK:STDOUT: %.loc45_10.3: type = converted %.loc45_10.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  114. // CHECK:STDOUT: }
  115. // CHECK:STDOUT: %x2: ref %empty_tuple.type = bind_name x2, %x2.var
  116. // CHECK:STDOUT: name_binding_decl {
  117. // CHECK:STDOUT: %y.patt: bool = binding_pattern y
  118. // CHECK:STDOUT: %.loc59_1: bool = var_pattern %y.patt
  119. // CHECK:STDOUT: }
  120. // CHECK:STDOUT: %y.var: ref bool = var y
  121. // CHECK:STDOUT: %.loc59_8.1: type = splice_block %.loc59_8.3 [template = bool] {
  122. // CHECK:STDOUT: %bool.make_type.loc59: init type = call constants.%Bool() [template = bool]
  123. // CHECK:STDOUT: %.loc59_8.2: type = value_of_initializer %bool.make_type.loc59 [template = bool]
  124. // CHECK:STDOUT: %.loc59_8.3: type = converted %bool.make_type.loc59, %.loc59_8.2 [template = bool]
  125. // CHECK:STDOUT: }
  126. // CHECK:STDOUT: %y: ref bool = bind_name y, %y.var
  127. // CHECK:STDOUT: name_binding_decl {
  128. // CHECK:STDOUT: %y2.patt: bool = binding_pattern y2
  129. // CHECK:STDOUT: %.loc73_1: bool = var_pattern %y2.patt
  130. // CHECK:STDOUT: }
  131. // CHECK:STDOUT: %y2.var: ref bool = var y2
  132. // CHECK:STDOUT: %.loc73_9.1: type = splice_block %.loc73_9.3 [template = bool] {
  133. // CHECK:STDOUT: %bool.make_type.loc73: init type = call constants.%Bool() [template = bool]
  134. // CHECK:STDOUT: %.loc73_9.2: type = value_of_initializer %bool.make_type.loc73 [template = bool]
  135. // CHECK:STDOUT: %.loc73_9.3: type = converted %bool.make_type.loc73, %.loc73_9.2 [template = bool]
  136. // CHECK:STDOUT: }
  137. // CHECK:STDOUT: %y2: ref bool = bind_name y2, %y2.var
  138. // CHECK:STDOUT: }
  139. // CHECK:STDOUT:
  140. // CHECK:STDOUT: fn @__global_init() {
  141. // CHECK:STDOUT: !entry:
  142. // CHECK:STDOUT: %true: bool = bool_literal true [template = constants.%true]
  143. // CHECK:STDOUT: if %true br !if.expr.then else br !if.expr.else
  144. // CHECK:STDOUT: }
  145. // CHECK:STDOUT: