fail_base_unbound.carbon 3.2 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. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/fail_base_unbound.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/fail_base_unbound.carbon
  10. base class B {}
  11. class C {
  12. extend base: B;
  13. }
  14. // CHECK:STDERR: fail_base_unbound.carbon:[[@LINE+3]]:12: error: expression cannot be used as a value [UseOfNonExprAsValue]
  15. // CHECK:STDERR: let b: B = C.base;
  16. // CHECK:STDERR: ^~~~~~
  17. let b: B = C.base;
  18. // CHECK:STDOUT: --- fail_base_unbound.carbon
  19. // CHECK:STDOUT:
  20. // CHECK:STDOUT: constants {
  21. // CHECK:STDOUT: %B: type = class_type @B [template]
  22. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  23. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  24. // CHECK:STDOUT: %C: type = class_type @C [template]
  25. // CHECK:STDOUT: %.4: type = unbound_element_type %C, %B [template]
  26. // CHECK:STDOUT: %.5: type = struct_type {.base: %B} [template]
  27. // CHECK:STDOUT: %.6: <witness> = complete_type_witness %.5 [template]
  28. // CHECK:STDOUT: }
  29. // CHECK:STDOUT:
  30. // CHECK:STDOUT: imports {
  31. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  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: .B = %B.decl
  41. // CHECK:STDOUT: .C = %C.decl
  42. // CHECK:STDOUT: .b = @__global_init.%b
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT: %Core.import = import Core
  45. // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} {}
  46. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  47. // CHECK:STDOUT: %B.ref: type = name_ref B, %B.decl [template = constants.%B]
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT:
  50. // CHECK:STDOUT: class @B {
  51. // CHECK:STDOUT: %.loc11: <witness> = complete_type_witness %.1 [template = constants.%.2]
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: !members:
  54. // CHECK:STDOUT: .Self = constants.%B
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT:
  57. // CHECK:STDOUT: class @C {
  58. // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [template = constants.%B]
  59. // CHECK:STDOUT: %.loc14: %.4 = base_decl %B, element0 [template]
  60. // CHECK:STDOUT: %.loc15: <witness> = complete_type_witness %.5 [template = constants.%.6]
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: !members:
  63. // CHECK:STDOUT: .Self = constants.%C
  64. // CHECK:STDOUT: .base = %.loc14
  65. // CHECK:STDOUT: extend %B.ref
  66. // CHECK:STDOUT: }
  67. // CHECK:STDOUT:
  68. // CHECK:STDOUT: fn @__global_init() {
  69. // CHECK:STDOUT: !entry:
  70. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  71. // CHECK:STDOUT: %base.ref: %.4 = name_ref base, @C.%.loc14 [template = @C.%.loc14]
  72. // CHECK:STDOUT: %b: %B = bind_name b, <error>
  73. // CHECK:STDOUT: return
  74. // CHECK:STDOUT: }
  75. // CHECK:STDOUT: