fail_base_unbound.carbon 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  6. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  7. //
  8. // AUTOUPDATE
  9. // TIP: To test this file alone, run:
  10. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/fail_base_unbound.carbon
  11. // TIP: To dump output, run:
  12. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/fail_base_unbound.carbon
  13. base class B {}
  14. class C {
  15. extend base: B;
  16. }
  17. // CHECK:STDERR: fail_base_unbound.carbon:[[@LINE+4]]:12: error: expression cannot be used as a value [UseOfNonExprAsValue]
  18. // CHECK:STDERR: let b: B = C.base;
  19. // CHECK:STDERR: ^~~~~~
  20. // CHECK:STDERR:
  21. let b: B = C.base;
  22. // CHECK:STDOUT: --- fail_base_unbound.carbon
  23. // CHECK:STDOUT:
  24. // CHECK:STDOUT: constants {
  25. // CHECK:STDOUT: %B: type = class_type @B [concrete]
  26. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  27. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [concrete]
  28. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  29. // CHECK:STDOUT: %C.elem: type = unbound_element_type %C, %B [concrete]
  30. // CHECK:STDOUT: %struct_type.base.0ff: type = struct_type {.base: %B} [concrete]
  31. // CHECK:STDOUT: %complete_type.98e: <witness> = complete_type_witness %struct_type.base.0ff [concrete]
  32. // CHECK:STDOUT: %pattern_type: type = pattern_type %B [concrete]
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: imports {
  36. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  37. // CHECK:STDOUT: import Core//prelude
  38. // CHECK:STDOUT: import Core//prelude/...
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: file {
  43. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  44. // CHECK:STDOUT: .Core = imports.%Core
  45. // CHECK:STDOUT: .B = %B.decl
  46. // CHECK:STDOUT: .C = %C.decl
  47. // CHECK:STDOUT: .b = %b
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT: %Core.import = import Core
  50. // CHECK:STDOUT: %B.decl: type = class_decl @B [concrete = constants.%B] {} {}
  51. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  52. // CHECK:STDOUT: name_binding_decl {
  53. // CHECK:STDOUT: %b.patt: %pattern_type = binding_pattern b [concrete]
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT: %B.ref: type = name_ref B, %B.decl [concrete = constants.%B]
  56. // CHECK:STDOUT: %b: %B = bind_name b, <error> [concrete = <error>]
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: class @B {
  60. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
  61. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type.357]
  62. // CHECK:STDOUT: complete_type_witness = %complete_type
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: !members:
  65. // CHECK:STDOUT: .Self = constants.%B
  66. // CHECK:STDOUT: }
  67. // CHECK:STDOUT:
  68. // CHECK:STDOUT: class @C {
  69. // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [concrete = constants.%B]
  70. // CHECK:STDOUT: %.loc17: %C.elem = base_decl %B.ref, element0 [concrete]
  71. // CHECK:STDOUT: %struct_type.base: type = struct_type {.base: %B} [concrete = constants.%struct_type.base.0ff]
  72. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.base [concrete = constants.%complete_type.98e]
  73. // CHECK:STDOUT: complete_type_witness = %complete_type
  74. // CHECK:STDOUT:
  75. // CHECK:STDOUT: !members:
  76. // CHECK:STDOUT: .Self = constants.%C
  77. // CHECK:STDOUT: .B = <poisoned>
  78. // CHECK:STDOUT: .base = %.loc17
  79. // CHECK:STDOUT: extend %B.ref
  80. // CHECK:STDOUT: }
  81. // CHECK:STDOUT:
  82. // CHECK:STDOUT: fn @__global_init() {
  83. // CHECK:STDOUT: !entry:
  84. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
  85. // CHECK:STDOUT: %base.ref: %C.elem = name_ref base, @C.%.loc17 [concrete = @C.%.loc17]
  86. // CHECK:STDOUT: return
  87. // CHECK:STDOUT: }
  88. // CHECK:STDOUT: