fail_convert_to_invalid.carbon 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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+4]]:10: error: name `NoSuchType` not found [NameNotFound]
  12. // CHECK:STDERR: var a: NoSuchType;
  13. // CHECK:STDERR: ^~~~~~~~~~
  14. // CHECK:STDERR:
  15. var a: NoSuchType;
  16. }
  17. fn Make() -> C {
  18. return {.a = 123};
  19. }
  20. // CHECK:STDOUT: --- fail_convert_to_invalid.carbon
  21. // CHECK:STDOUT:
  22. // CHECK:STDOUT: constants {
  23. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  24. // CHECK:STDOUT: %Make.type: type = fn_type @Make [concrete]
  25. // CHECK:STDOUT: %Make: %Make.type = struct_value () [concrete]
  26. // CHECK:STDOUT: %int_123: Core.IntLiteral = int_value 123 [concrete]
  27. // CHECK:STDOUT: %struct_type.a: type = struct_type {.a: Core.IntLiteral} [concrete]
  28. // CHECK:STDOUT: }
  29. // CHECK:STDOUT:
  30. // CHECK:STDOUT: imports {
  31. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  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 [concrete] {
  39. // CHECK:STDOUT: .Core = imports.%Core
  40. // CHECK:STDOUT: .C = %C.decl
  41. // CHECK:STDOUT: .NoSuchType = <poisoned>
  42. // CHECK:STDOUT: .Make = %Make.decl
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT: %Core.import = import Core
  45. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  46. // CHECK:STDOUT: %Make.decl: %Make.type = fn_decl @Make [concrete = constants.%Make] {
  47. // CHECK:STDOUT: %return.patt: %C = return_slot_pattern
  48. // CHECK:STDOUT: %return.param_patt: %C = out_param_pattern %return.patt, call_param0
  49. // CHECK:STDOUT: } {
  50. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
  51. // CHECK:STDOUT: %return.param: ref %C = out_param call_param0
  52. // CHECK:STDOUT: %return: ref %C = return_slot %return.param
  53. // CHECK:STDOUT: }
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: class @C {
  57. // CHECK:STDOUT: %.loc16_8: <error> = field_decl a, element0 [concrete]
  58. // CHECK:STDOUT: name_binding_decl {
  59. // CHECK:STDOUT: %.loc16_3: <error> = var_pattern %.loc16_8
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT: %.var: ref <error> = var <none>
  62. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness <error> [concrete = <error>]
  63. // CHECK:STDOUT: complete_type_witness = %complete_type
  64. // CHECK:STDOUT:
  65. // CHECK:STDOUT: !members:
  66. // CHECK:STDOUT: .Self = constants.%C
  67. // CHECK:STDOUT: .NoSuchType = <poisoned>
  68. // CHECK:STDOUT: .a = %.loc16_8
  69. // CHECK:STDOUT: }
  70. // CHECK:STDOUT:
  71. // CHECK:STDOUT: fn @Make() -> %return.param_patt: %C {
  72. // CHECK:STDOUT: !entry:
  73. // CHECK:STDOUT: %int_123: Core.IntLiteral = int_value 123 [concrete = constants.%int_123]
  74. // CHECK:STDOUT: %.loc20: %struct_type.a = struct_literal (%int_123)
  75. // CHECK:STDOUT: return <error> to %return
  76. // CHECK:STDOUT: }
  77. // CHECK:STDOUT: