fail_assoc_const_template.carbon 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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/interface/fail_assoc_const_template.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interface/fail_assoc_const_template.carbon
  14. interface I {
  15. // CHECK:STDERR: fail_assoc_const_template.carbon:[[@LINE+4]]:20: error: associated constant has `template` binding [TemplateBindingInAssociatedConstantDecl]
  16. // CHECK:STDERR: let template T:! type;
  17. // CHECK:STDERR: ^~~~
  18. // CHECK:STDERR:
  19. let template T:! type;
  20. }
  21. // CHECK:STDOUT: --- fail_assoc_const_template.carbon
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: constants {
  24. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  25. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic]
  26. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
  27. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%T [concrete]
  28. // CHECK:STDOUT: }
  29. // CHECK:STDOUT:
  30. // CHECK:STDOUT: file {
  31. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  32. // CHECK:STDOUT: .I = %I.decl
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT: %I.decl: type = interface_decl @I [concrete = constants.%I.type] {} {}
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT:
  37. // CHECK:STDOUT: interface @I {
  38. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  39. // CHECK:STDOUT: %T: type = assoc_const_decl @T [concrete] {
  40. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%T [concrete = constants.%assoc0]
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT:
  43. // CHECK:STDOUT: !members:
  44. // CHECK:STDOUT: .Self = %Self
  45. // CHECK:STDOUT: .T = @T.%assoc0
  46. // CHECK:STDOUT: witness = (%T)
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT:
  49. // CHECK:STDOUT: generic assoc_const @T(@I.%Self: %I.type) {
  50. // CHECK:STDOUT: assoc_const T:! type;
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: specific @T(constants.%Self) {}
  54. // CHECK:STDOUT: