fail_impl_bad_assoc_const.carbon 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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/impl/fail_impl_bad_assoc_const.carbon
  11. // TIP: To dump output, run:
  12. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/fail_impl_bad_assoc_const.carbon
  13. interface I { let T:! type; }
  14. // CHECK:STDERR: fail_impl_bad_assoc_const.carbon:[[@LINE+7]]:1: error: associated constant T not given a value in impl of interface I [ImplAssociatedConstantNeedsValue]
  15. // CHECK:STDERR: impl () as I {}
  16. // CHECK:STDERR: ^~~~~~~~~~~~~~
  17. // CHECK:STDERR: fail_impl_bad_assoc_const.carbon:[[@LINE-5]]:19: note: associated constant declared here [AssociatedConstantHere]
  18. // CHECK:STDERR: interface I { let T:! type; }
  19. // CHECK:STDERR: ^~~~~~~~
  20. // CHECK:STDERR:
  21. impl () as I {}
  22. // CHECK:STDOUT: --- fail_impl_bad_assoc_const.carbon
  23. // CHECK:STDOUT:
  24. // CHECK:STDOUT: constants {
  25. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  26. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic]
  27. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
  28. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%T [concrete]
  29. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  30. // CHECK:STDOUT: %I.impl_witness: <witness> = impl_witness file.%I.impl_witness_table [concrete]
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT:
  33. // CHECK:STDOUT: file {
  34. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  35. // CHECK:STDOUT: .I = %I.decl
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT: %I.decl: type = interface_decl @I [concrete = constants.%I.type] {} {}
  38. // CHECK:STDOUT: impl_decl @impl [concrete] {} {
  39. // CHECK:STDOUT: %.loc23_7.1: %empty_tuple.type = tuple_literal ()
  40. // CHECK:STDOUT: %.loc23_7.2: type = converted %.loc23_7.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  41. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [concrete = constants.%I.type]
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT: %I.impl_witness_table = impl_witness_table (<error>), @impl [concrete]
  44. // CHECK:STDOUT: %I.impl_witness: <witness> = impl_witness %I.impl_witness_table [concrete = constants.%I.impl_witness]
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: interface @I {
  48. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  49. // CHECK:STDOUT: %T: type = assoc_const_decl @T [concrete] {
  50. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%T [concrete = constants.%assoc0]
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: !members:
  54. // CHECK:STDOUT: .Self = %Self
  55. // CHECK:STDOUT: .T = @T.%assoc0
  56. // CHECK:STDOUT: witness = (%T)
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: generic assoc_const @T(@I.%Self: %I.type) {
  60. // CHECK:STDOUT: assoc_const T:! type;
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT:
  63. // CHECK:STDOUT: impl @impl: %.loc23_7.2 as %I.ref {
  64. // CHECK:STDOUT: !members:
  65. // CHECK:STDOUT: witness = file.%I.impl_witness
  66. // CHECK:STDOUT: }
  67. // CHECK:STDOUT:
  68. // CHECK:STDOUT: specific @T(constants.%Self) {}
  69. // CHECK:STDOUT: