fail_base_unbound.carbon 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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+4]]:12: error: expression cannot be used as a value [UseOfNonExprAsValue]
  15. // CHECK:STDERR: let b: B = C.base;
  16. // CHECK:STDERR: ^~~~~~
  17. // CHECK:STDERR:
  18. let b: B = C.base;
  19. // CHECK:STDOUT: --- fail_base_unbound.carbon
  20. // CHECK:STDOUT:
  21. // CHECK:STDOUT: constants {
  22. // CHECK:STDOUT: %B: type = class_type @B [concrete]
  23. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  24. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [concrete]
  25. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  26. // CHECK:STDOUT: %C.elem: type = unbound_element_type %C, %B [concrete]
  27. // CHECK:STDOUT: %struct_type.base.0ff: type = struct_type {.base: %B} [concrete]
  28. // CHECK:STDOUT: %complete_type.98e: <witness> = complete_type_witness %struct_type.base.0ff [concrete]
  29. // CHECK:STDOUT: }
  30. // CHECK:STDOUT:
  31. // CHECK:STDOUT: imports {
  32. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  33. // CHECK:STDOUT: import Core//prelude
  34. // CHECK:STDOUT: import Core//prelude/...
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT:
  38. // CHECK:STDOUT: file {
  39. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  40. // CHECK:STDOUT: .Core = imports.%Core
  41. // CHECK:STDOUT: .B = %B.decl
  42. // CHECK:STDOUT: .C = %C.decl
  43. // CHECK:STDOUT: .b = %b
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT: %Core.import = import Core
  46. // CHECK:STDOUT: %B.decl: type = class_decl @B [concrete = constants.%B] {} {}
  47. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  48. // CHECK:STDOUT: name_binding_decl {
  49. // CHECK:STDOUT: %b.patt: %B = binding_pattern b
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT: %B.ref: type = name_ref B, %B.decl [concrete = constants.%B]
  52. // CHECK:STDOUT: %b: %B = bind_name b, <error>
  53. // CHECK:STDOUT: }
  54. // CHECK:STDOUT:
  55. // CHECK:STDOUT: class @B {
  56. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type.357]
  57. // CHECK:STDOUT: complete_type_witness = %complete_type
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: !members:
  60. // CHECK:STDOUT: .Self = constants.%B
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT:
  63. // CHECK:STDOUT: class @C {
  64. // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [concrete = constants.%B]
  65. // CHECK:STDOUT: %.loc14: %C.elem = base_decl %B.ref, element0 [concrete]
  66. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.base.0ff [concrete = constants.%complete_type.98e]
  67. // CHECK:STDOUT: complete_type_witness = %complete_type
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: !members:
  70. // CHECK:STDOUT: .Self = constants.%C
  71. // CHECK:STDOUT: .B = <poisoned>
  72. // CHECK:STDOUT: .base = %.loc14
  73. // CHECK:STDOUT: extend %B.ref
  74. // CHECK:STDOUT: }
  75. // CHECK:STDOUT:
  76. // CHECK:STDOUT: fn @__global_init() {
  77. // CHECK:STDOUT: !entry:
  78. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
  79. // CHECK:STDOUT: %base.ref: %C.elem = name_ref base, @C.%.loc14 [concrete = @C.%.loc14]
  80. // CHECK:STDOUT: return
  81. // CHECK:STDOUT: }
  82. // CHECK:STDOUT: