fail_convert_to_invalid.carbon 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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: %.1: type = tuple_type () [template]
  25. // CHECK:STDOUT: %Make: %Make.type = struct_value () [template]
  26. // CHECK:STDOUT: %.2: i32 = int_value 123 [template]
  27. // CHECK:STDOUT: %.3: type = struct_type {.a: i32} [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: .C = %C.decl
  41. // CHECK:STDOUT: .Make = %Make.decl
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT: %Core.import = import Core
  44. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  45. // CHECK:STDOUT: %Make.decl: %Make.type = fn_decl @Make [template = constants.%Make] {
  46. // CHECK:STDOUT: %return.patt: %C = return_slot_pattern
  47. // CHECK:STDOUT: %return.param_patt: %C = out_param_pattern %return.patt, runtime_param0
  48. // CHECK:STDOUT: } {
  49. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  50. // CHECK:STDOUT: %return.param: ref %C = out_param runtime_param0
  51. // CHECK:STDOUT: %return: ref %C = return_slot %return.param
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT: }
  54. // CHECK:STDOUT:
  55. // CHECK:STDOUT: class @C {
  56. // CHECK:STDOUT: %NoSuchType.ref: <error> = name_ref NoSuchType, <error> [template = <error>]
  57. // CHECK:STDOUT: %.loc15: <error> = field_decl a, element0 [template]
  58. // CHECK:STDOUT: %.loc16: <witness> = complete_type_witness <error> [template = <error>]
  59. // CHECK:STDOUT:
  60. // CHECK:STDOUT: !members:
  61. // CHECK:STDOUT: .Self = constants.%C
  62. // CHECK:STDOUT: .a = %.loc15
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT:
  65. // CHECK:STDOUT: fn @Make() -> %return: %C {
  66. // CHECK:STDOUT: !entry:
  67. // CHECK:STDOUT: %.loc19_16: i32 = int_value 123 [template = constants.%.2]
  68. // CHECK:STDOUT: %.loc19_19: %.3 = struct_literal (%.loc19_16)
  69. // CHECK:STDOUT: return <error> to %return
  70. // CHECK:STDOUT: }
  71. // CHECK:STDOUT: