fail_assoc_const_bad_default.carbon 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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+6]]:3: error: cannot implicitly convert from `Core.IntLiteral` to `type` [ImplicitAsConversionFailure]
  12. // CHECK:STDERR: let T:! type = 42;
  13. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~
  14. // CHECK:STDERR: fail_assoc_const_bad_default.carbon:[[@LINE+3]]:3: note: type `Core.IntLiteral` does not implement interface `Core.ImplicitAs(type)` [MissingImplInMemberAccessNote]
  15. // CHECK:STDERR: let T:! type = 42;
  16. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~
  17. let T:! type = 42;
  18. }
  19. // CHECK:STDOUT: --- fail_assoc_const_bad_default.carbon
  20. // CHECK:STDOUT:
  21. // CHECK:STDOUT: constants {
  22. // CHECK:STDOUT: %I.type: type = facet_type <@I> [template]
  23. // CHECK:STDOUT: %Self.1: %I.type = bind_symbolic_name Self, 0 [symbolic]
  24. // CHECK:STDOUT: %int_42: Core.IntLiteral = int_value 42 [template]
  25. // CHECK:STDOUT: %assoc_type: type = assoc_entity_type %I.type, type [template]
  26. // CHECK:STDOUT: %assoc0.4: %assoc_type = assoc_entity element0, @I.%T [template]
  27. // CHECK:STDOUT: }
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: imports {
  30. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  31. // CHECK:STDOUT: .ImplicitAs = %import_ref.1
  32. // CHECK:STDOUT: import Core//prelude
  33. // CHECK:STDOUT: import Core//prelude/...
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT:
  37. // CHECK:STDOUT: file {
  38. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  39. // CHECK:STDOUT: .Core = imports.%Core
  40. // CHECK:STDOUT: .I = %I.decl
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT: %Core.import = import Core
  43. // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%I.type] {} {}
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT:
  46. // CHECK:STDOUT: interface @I {
  47. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.1]
  48. // CHECK:STDOUT: %int_42: Core.IntLiteral = int_value 42 [template = constants.%int_42]
  49. // CHECK:STDOUT: %.loc18: type = converted %int_42, <error> [template = <error>]
  50. // CHECK:STDOUT: %T: type = assoc_const_decl T [template]
  51. // CHECK:STDOUT: %assoc0: %assoc_type = assoc_entity element0, %T [template = constants.%assoc0.4]
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: !members:
  54. // CHECK:STDOUT: .Self = %Self
  55. // CHECK:STDOUT: .T = %assoc0
  56. // CHECK:STDOUT: witness = (%T)
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT: