fail_impl_bad_assoc_const.carbon 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/none.carbon
  6. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  7. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  8. //
  9. // AUTOUPDATE
  10. // TIP: To test this file alone, run:
  11. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/impl/fail_impl_bad_assoc_const.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/fail_impl_bad_assoc_const.carbon
  14. interface I { let T:! type; }
  15. // 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]
  16. // CHECK:STDERR: impl () as I {}
  17. // CHECK:STDERR: ^~~~~~~~~~~~~~
  18. // CHECK:STDERR: fail_impl_bad_assoc_const.carbon:[[@LINE-5]]:19: note: associated constant declared here [AssociatedConstantHere]
  19. // CHECK:STDERR: interface I { let T:! type; }
  20. // CHECK:STDERR: ^~~~~~~~
  21. // CHECK:STDERR:
  22. impl () as I {}
  23. // CHECK:STDOUT: --- fail_impl_bad_assoc_const.carbon
  24. // CHECK:STDOUT:
  25. // CHECK:STDOUT: constants {
  26. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  27. // CHECK:STDOUT: %Self: %I.type = symbolic_binding Self, 0 [symbolic]
  28. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
  29. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.WithSelf.%T [concrete]
  30. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  31. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
  32. // CHECK:STDOUT: %I.impl_witness: <witness> = impl_witness @empty_tuple.type.as.I.impl.%I.impl_witness_table [concrete]
  33. // CHECK:STDOUT: %I.facet: %I.type = facet_value %empty_tuple.type, (%I.impl_witness) [concrete]
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT:
  36. // CHECK:STDOUT: file {
  37. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  38. // CHECK:STDOUT: .I = %I.decl
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT: %I.decl: type = interface_decl @I [concrete = constants.%I.type] {} {}
  41. // CHECK:STDOUT: impl_decl @empty_tuple.type.as.I.impl [concrete] {} {
  42. // CHECK:STDOUT: %.loc24_7.1: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
  43. // CHECK:STDOUT: %.loc24_7.2: type = converted %.loc24_7.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  44. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [concrete = constants.%I.type]
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT:
  48. // CHECK:STDOUT: interface @I {
  49. // CHECK:STDOUT: %Self: %I.type = symbolic_binding Self, 0 [symbolic = constants.%Self]
  50. // CHECK:STDOUT: %I.WithSelf.decl = interface_with_self_decl @I [concrete]
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: !with Self:
  53. // CHECK:STDOUT: %T: type = assoc_const_decl @T [concrete] {
  54. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.WithSelf.%T [concrete = constants.%assoc0]
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT:
  57. // CHECK:STDOUT: !members:
  58. // CHECK:STDOUT: .Self = %Self
  59. // CHECK:STDOUT: .T = @T.%assoc0
  60. // CHECK:STDOUT: witness = (@I.WithSelf.%T)
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: !requires:
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT:
  65. // CHECK:STDOUT: impl @empty_tuple.type.as.I.impl: %.loc24_7.2 as %I.ref {
  66. // CHECK:STDOUT: %I.impl_witness_table = impl_witness_table (<error>), @empty_tuple.type.as.I.impl [concrete]
  67. // CHECK:STDOUT: %I.impl_witness: <witness> = impl_witness %I.impl_witness_table [concrete = constants.%I.impl_witness]
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: !members:
  70. // CHECK:STDOUT: witness = %I.impl_witness
  71. // CHECK:STDOUT: }
  72. // CHECK:STDOUT:
  73. // CHECK:STDOUT: specific @I.WithSelf(constants.%Self) {
  74. // CHECK:STDOUT: !definition:
  75. // CHECK:STDOUT: }
  76. // CHECK:STDOUT:
  77. // CHECK:STDOUT: specific @I.WithSelf(constants.%I.facet) {
  78. // CHECK:STDOUT: !definition:
  79. // CHECK:STDOUT: }
  80. // CHECK:STDOUT: