fail_convert_to_invalid.carbon 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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_convert_to_invalid.carbon
  11. // TIP: To dump output, run:
  12. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/fail_convert_to_invalid.carbon
  13. class C {
  14. // CHECK:STDERR: fail_convert_to_invalid.carbon:[[@LINE+4]]:10: error: name `NoSuchType` not found [NameNotFound]
  15. // CHECK:STDERR: var a: NoSuchType;
  16. // CHECK:STDERR: ^~~~~~~~~~
  17. // CHECK:STDERR:
  18. var a: NoSuchType;
  19. }
  20. fn Make() -> C {
  21. return {.a = 123};
  22. }
  23. // CHECK:STDOUT: --- fail_convert_to_invalid.carbon
  24. // CHECK:STDOUT:
  25. // CHECK:STDOUT: constants {
  26. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  27. // CHECK:STDOUT: %pattern_type: type = pattern_type %C [concrete]
  28. // CHECK:STDOUT: %Make.type: type = fn_type @Make [concrete]
  29. // CHECK:STDOUT: %Make: %Make.type = struct_value () [concrete]
  30. // CHECK:STDOUT: %int_123: Core.IntLiteral = int_value 123 [concrete]
  31. // CHECK:STDOUT: %struct_type.a: type = struct_type {.a: Core.IntLiteral} [concrete]
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT:
  34. // CHECK:STDOUT: imports {
  35. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  36. // CHECK:STDOUT: import Core//prelude
  37. // CHECK:STDOUT: import Core//prelude/...
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: file {
  42. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  43. // CHECK:STDOUT: .Core = imports.%Core
  44. // CHECK:STDOUT: .C = %C.decl
  45. // CHECK:STDOUT: .NoSuchType = <poisoned>
  46. // CHECK:STDOUT: .Make = %Make.decl
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT: %Core.import = import Core
  49. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  50. // CHECK:STDOUT: %Make.decl: %Make.type = fn_decl @Make [concrete = constants.%Make] {
  51. // CHECK:STDOUT: %return.patt: %pattern_type = return_slot_pattern [concrete]
  52. // CHECK:STDOUT: %return.param_patt: %pattern_type = out_param_pattern %return.patt, call_param0 [concrete]
  53. // CHECK:STDOUT: } {
  54. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
  55. // CHECK:STDOUT: %return.param: ref %C = out_param call_param0
  56. // CHECK:STDOUT: %return: ref %C = return_slot %return.param
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT: }
  59. // CHECK:STDOUT:
  60. // CHECK:STDOUT: class @C {
  61. // CHECK:STDOUT: %NoSuchType.ref: <error> = name_ref NoSuchType, <error> [concrete = <error>]
  62. // CHECK:STDOUT: %.loc19: <error> = field_decl a, element0 [concrete]
  63. // CHECK:STDOUT: %struct_type.a: type = struct_type {.a: <error>} [concrete = <error>]
  64. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.a [concrete = <error>]
  65. // CHECK:STDOUT: complete_type_witness = %complete_type
  66. // CHECK:STDOUT:
  67. // CHECK:STDOUT: !members:
  68. // CHECK:STDOUT: .Self = constants.%C
  69. // CHECK:STDOUT: .NoSuchType = <poisoned>
  70. // CHECK:STDOUT: .a = %.loc19
  71. // CHECK:STDOUT: }
  72. // CHECK:STDOUT:
  73. // CHECK:STDOUT: fn @Make() -> %return.param: %C {
  74. // CHECK:STDOUT: !entry:
  75. // CHECK:STDOUT: %int_123: Core.IntLiteral = int_value 123 [concrete = constants.%int_123]
  76. // CHECK:STDOUT: %.loc23: %struct_type.a = struct_literal (%int_123)
  77. // CHECK:STDOUT: return <error> to %return
  78. // CHECK:STDOUT: }
  79. // CHECK:STDOUT: