fail_assoc_const_bad_default.carbon 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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/fail_assoc_const_bad_default.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interface/fail_assoc_const_bad_default.carbon
  10. interface I {
  11. // CHECK:STDERR: fail_assoc_const_bad_default.carbon:[[@LINE+3]]:3: ERROR: Cannot implicitly convert from `i32` to `type`.
  12. // CHECK:STDERR: let T:! type = 42;
  13. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~
  14. let T:! type = 42;
  15. }
  16. // CHECK:STDOUT: --- fail_assoc_const_bad_default.carbon
  17. // CHECK:STDOUT:
  18. // CHECK:STDOUT: constants {
  19. // CHECK:STDOUT: %.1: type = interface_type @I [template]
  20. // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic]
  21. // CHECK:STDOUT: %.2: i32 = int_literal 42 [template]
  22. // CHECK:STDOUT: %.3: type = assoc_entity_type @I, type [template]
  23. // CHECK:STDOUT: %.4: %.3 = assoc_entity element0, @I.%T [template]
  24. // CHECK:STDOUT: }
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: file {
  27. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  28. // CHECK:STDOUT: .Core = %Core
  29. // CHECK:STDOUT: .I = %I.decl
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  32. // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {}
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: interface @I {
  36. // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = constants.%Self]
  37. // CHECK:STDOUT: %.loc15_18: i32 = int_literal 42 [template = constants.%.2]
  38. // CHECK:STDOUT: %T: type = assoc_const_decl T [template]
  39. // CHECK:STDOUT: %.loc15_20: %.3 = assoc_entity element0, %T [template = constants.%.4]
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: !members:
  42. // CHECK:STDOUT: .Self = %Self
  43. // CHECK:STDOUT: .T = %.loc15_20
  44. // CHECK:STDOUT: witness = (%T)
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT: