fail_assoc_const_bad_default.carbon 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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/int.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_bad_default.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_bad_default.carbon
  14. interface I {
  15. // CHECK:STDERR: fail_assoc_const_bad_default.carbon:[[@LINE+7]]:3: error: cannot implicitly convert non-type value of type `Core.IntLiteral` to `type` [ConversionFailureNonTypeToFacet]
  16. // CHECK:STDERR: let T:! type = 42;
  17. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~
  18. // CHECK:STDERR: fail_assoc_const_bad_default.carbon:[[@LINE+4]]:3: note: type `Core.IntLiteral` does not implement interface `Core.ImplicitAs(type)` [MissingImplInMemberAccessNote]
  19. // CHECK:STDERR: let T:! type = 42;
  20. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~
  21. // CHECK:STDERR:
  22. let T:! type = 42;
  23. }
  24. // CHECK:STDOUT: --- fail_assoc_const_bad_default.carbon
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: constants {
  27. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  28. // CHECK:STDOUT: %Self.9f2: %I.type = symbolic_binding Self, 0 [symbolic]
  29. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
  30. // CHECK:STDOUT: %assoc0.cd1: %I.assoc_type = assoc_entity element0, @I.%T [concrete]
  31. // CHECK:STDOUT: %int_42: Core.IntLiteral = int_value 42 [concrete]
  32. // CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
  33. // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT:
  36. // CHECK:STDOUT: imports {
  37. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  38. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  39. // CHECK:STDOUT: import Core//prelude
  40. // CHECK:STDOUT: import Core//prelude/...
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/parts/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT:
  45. // CHECK:STDOUT: file {
  46. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  47. // CHECK:STDOUT: .Core = imports.%Core
  48. // CHECK:STDOUT: .I = %I.decl
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT: %Core.import = import Core
  51. // CHECK:STDOUT: %I.decl: type = interface_decl @I [concrete = constants.%I.type] {} {}
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT:
  54. // CHECK:STDOUT: interface @I {
  55. // CHECK:STDOUT: %Self: %I.type = symbolic_binding Self, 0 [symbolic = constants.%Self.9f2]
  56. // CHECK:STDOUT: %T: type = assoc_const_decl @T [concrete] {
  57. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%T [concrete = constants.%assoc0.cd1]
  58. // CHECK:STDOUT: %int_42: Core.IntLiteral = int_value 42 [concrete = constants.%int_42]
  59. // CHECK:STDOUT: %.loc23: type = converted %int_42, <error> [concrete = <error>]
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: !members:
  63. // CHECK:STDOUT: .Self = %Self
  64. // CHECK:STDOUT: .T = @T.%assoc0
  65. // CHECK:STDOUT: witness = (%T)
  66. // CHECK:STDOUT:
  67. // CHECK:STDOUT: !requires:
  68. // CHECK:STDOUT: }
  69. // CHECK:STDOUT:
  70. // CHECK:STDOUT: generic assoc_const @T(@I.%Self: %I.type) {
  71. // CHECK:STDOUT: !definition:
  72. // CHECK:STDOUT:
  73. // CHECK:STDOUT: assoc_const T:! type = <error>;
  74. // CHECK:STDOUT: }
  75. // CHECK:STDOUT:
  76. // CHECK:STDOUT: specific @T(constants.%Self.9f2) {}
  77. // CHECK:STDOUT: