fail_convert_to_invalid.carbon 3.1 KB

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