todo_define_not_default.carbon 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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/interface/todo_define_not_default.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interface/todo_define_not_default.carbon
  10. interface I {
  11. // TODO: A definition without `default` in an interface should be rejected.
  12. fn F() {}
  13. fn G(a: i32, b: i32) -> i32 = "int.sadd";
  14. // TODO: An associated constant with an initializer without `default` in an
  15. // interface should be rejected.
  16. let T:! type = (i32, i32);
  17. let N:! i32 = 42;
  18. }
  19. // CHECK:STDOUT: --- todo_define_not_default.carbon
  20. // CHECK:STDOUT:
  21. // CHECK:STDOUT: constants {
  22. // CHECK:STDOUT: %.1: type = interface_type @I [template]
  23. // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic]
  24. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  25. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  26. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  27. // CHECK:STDOUT: %.3: type = assoc_entity_type @I, %F.type [template]
  28. // CHECK:STDOUT: %.4: %.3 = assoc_entity element0, @I.%F.decl [template]
  29. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  30. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  31. // CHECK:STDOUT: %G.type: type = fn_type @G [template]
  32. // CHECK:STDOUT: %G: %G.type = struct_value () [template]
  33. // CHECK:STDOUT: %.5: type = assoc_entity_type @I, %G.type [template]
  34. // CHECK:STDOUT: %.6: %.5 = assoc_entity element1, @I.%G.decl [template]
  35. // CHECK:STDOUT: %.7: type = tuple_type (type, type) [template]
  36. // CHECK:STDOUT: %.8: type = tuple_type (i32, i32) [template]
  37. // CHECK:STDOUT: %.9: type = assoc_entity_type @I, type [template]
  38. // CHECK:STDOUT: %.10: %.9 = assoc_entity element2, @I.%T [template]
  39. // CHECK:STDOUT: %.11: i32 = int_literal 42 [template]
  40. // CHECK:STDOUT: %.12: type = assoc_entity_type @I, i32 [template]
  41. // CHECK:STDOUT: %.13: %.12 = assoc_entity element3, @I.%N [template]
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: imports {
  45. // CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  46. // CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  47. // CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  48. // CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  49. // CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  50. // CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: file {
  54. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  55. // CHECK:STDOUT: .Core = %Core
  56. // CHECK:STDOUT: .I = %I.decl
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT: %Core.import = import Core
  59. // CHECK:STDOUT: %Core: <namespace> = namespace %Core.import, [template] {
  60. // CHECK:STDOUT: import Core//prelude
  61. // CHECK:STDOUT: import Core//prelude/operators
  62. // CHECK:STDOUT: import Core//prelude/types
  63. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  64. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  65. // CHECK:STDOUT: import Core//prelude/operators/comparison
  66. // CHECK:STDOUT: import Core//prelude/types/bool
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {}
  69. // CHECK:STDOUT: }
  70. // CHECK:STDOUT:
  71. // CHECK:STDOUT: interface @I {
  72. // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = constants.%Self]
  73. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {}
  74. // CHECK:STDOUT: %.loc13: %.3 = assoc_entity element0, %F.decl [template = constants.%.4]
  75. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {
  76. // CHECK:STDOUT: %int.make_type_32.loc14_11: init type = call constants.%Int32() [template = i32]
  77. // CHECK:STDOUT: %.loc14_11.1: type = value_of_initializer %int.make_type_32.loc14_11 [template = i32]
  78. // CHECK:STDOUT: %.loc14_11.2: type = converted %int.make_type_32.loc14_11, %.loc14_11.1 [template = i32]
  79. // CHECK:STDOUT: %a.loc14_8.1: i32 = param a
  80. // CHECK:STDOUT: %a.loc14_8.2: i32 = bind_name a, %a.loc14_8.1
  81. // CHECK:STDOUT: %int.make_type_32.loc14_19: init type = call constants.%Int32() [template = i32]
  82. // CHECK:STDOUT: %.loc14_19.1: type = value_of_initializer %int.make_type_32.loc14_19 [template = i32]
  83. // CHECK:STDOUT: %.loc14_19.2: type = converted %int.make_type_32.loc14_19, %.loc14_19.1 [template = i32]
  84. // CHECK:STDOUT: %b.loc14_16.1: i32 = param b
  85. // CHECK:STDOUT: %b.loc14_16.2: i32 = bind_name b, %b.loc14_16.1
  86. // CHECK:STDOUT: %int.make_type_32.loc14_27: init type = call constants.%Int32() [template = i32]
  87. // CHECK:STDOUT: %.loc14_27.1: type = value_of_initializer %int.make_type_32.loc14_27 [template = i32]
  88. // CHECK:STDOUT: %.loc14_27.2: type = converted %int.make_type_32.loc14_27, %.loc14_27.1 [template = i32]
  89. // CHECK:STDOUT: %return.var: ref i32 = var <return slot>
  90. // CHECK:STDOUT: }
  91. // CHECK:STDOUT: %.loc14_31: %.5 = assoc_entity element1, %G.decl [template = constants.%.6]
  92. // CHECK:STDOUT: %int.make_type_32.loc18_19: init type = call constants.%Int32() [template = i32]
  93. // CHECK:STDOUT: %int.make_type_32.loc18_24: init type = call constants.%Int32() [template = i32]
  94. // CHECK:STDOUT: %.loc18_27: %.7 = tuple_literal (%int.make_type_32.loc18_19, %int.make_type_32.loc18_24)
  95. // CHECK:STDOUT: %.loc18_28.1: type = value_of_initializer %int.make_type_32.loc18_19 [template = i32]
  96. // CHECK:STDOUT: %.loc18_28.2: type = converted %int.make_type_32.loc18_19, %.loc18_28.1 [template = i32]
  97. // CHECK:STDOUT: %.loc18_28.3: type = value_of_initializer %int.make_type_32.loc18_24 [template = i32]
  98. // CHECK:STDOUT: %.loc18_28.4: type = converted %int.make_type_32.loc18_24, %.loc18_28.3 [template = i32]
  99. // CHECK:STDOUT: %.loc18_28.5: type = converted %.loc18_27, constants.%.8 [template = constants.%.8]
  100. // CHECK:STDOUT: %T: type = assoc_const_decl T [template]
  101. // CHECK:STDOUT: %.loc18_28.6: %.9 = assoc_entity element2, %T [template = constants.%.10]
  102. // CHECK:STDOUT: %int.make_type_32.loc19: init type = call constants.%Int32() [template = i32]
  103. // CHECK:STDOUT: %.loc19_11.1: type = value_of_initializer %int.make_type_32.loc19 [template = i32]
  104. // CHECK:STDOUT: %.loc19_11.2: type = converted %int.make_type_32.loc19, %.loc19_11.1 [template = i32]
  105. // CHECK:STDOUT: %.loc19_17: i32 = int_literal 42 [template = constants.%.11]
  106. // CHECK:STDOUT: %N: i32 = assoc_const_decl N [template]
  107. // CHECK:STDOUT: %.loc19_19: %.12 = assoc_entity element3, %N [template = constants.%.13]
  108. // CHECK:STDOUT:
  109. // CHECK:STDOUT: !members:
  110. // CHECK:STDOUT: .Self = %Self
  111. // CHECK:STDOUT: .F = %.loc13
  112. // CHECK:STDOUT: .G = %.loc14_31
  113. // CHECK:STDOUT: .T = %.loc18_28.6
  114. // CHECK:STDOUT: .N = %.loc19_19
  115. // CHECK:STDOUT: witness = (%F.decl, %G.decl, %T, %N)
  116. // CHECK:STDOUT: }
  117. // CHECK:STDOUT:
  118. // CHECK:STDOUT: generic fn @F(@I.%Self: %.1) {
  119. // CHECK:STDOUT: !definition:
  120. // CHECK:STDOUT:
  121. // CHECK:STDOUT: fn() {
  122. // CHECK:STDOUT: !entry:
  123. // CHECK:STDOUT: return
  124. // CHECK:STDOUT: }
  125. // CHECK:STDOUT: }
  126. // CHECK:STDOUT:
  127. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  128. // CHECK:STDOUT:
  129. // CHECK:STDOUT: generic fn @G(@I.%Self: %.1) {
  130. // CHECK:STDOUT:
  131. // CHECK:STDOUT: fn(@I.%a.loc14_8.2: i32, @I.%b.loc14_16.2: i32) -> i32 = "int.sadd";
  132. // CHECK:STDOUT: }
  133. // CHECK:STDOUT:
  134. // CHECK:STDOUT: specific @F(constants.%Self) {}
  135. // CHECK:STDOUT:
  136. // CHECK:STDOUT: specific @G(constants.%Self) {}
  137. // CHECK:STDOUT: