fail_assign_nested.carbon 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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/struct/no_prelude/fail_assign_nested.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/struct/no_prelude/fail_assign_nested.carbon
  10. // CHECK:STDERR: fail_assign_nested.carbon:[[@LINE+4]]:19: error: missing value for field `a` in struct initialization [StructInitMissingFieldInLiteral]
  11. // CHECK:STDERR: var x: {.a: {}} = {.b = {}};
  12. // CHECK:STDERR: ^~~~~~~~~
  13. // CHECK:STDERR:
  14. var x: {.a: {}} = {.b = {}};
  15. // CHECK:STDOUT: --- fail_assign_nested.carbon
  16. // CHECK:STDOUT:
  17. // CHECK:STDOUT: constants {
  18. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  19. // CHECK:STDOUT: %struct_type.a.225: type = struct_type {.a: %empty_struct_type} [concrete]
  20. // CHECK:STDOUT: %struct_type.b: type = struct_type {.b: %empty_struct_type} [concrete]
  21. // CHECK:STDOUT: }
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: file {
  24. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  25. // CHECK:STDOUT: .x = %x
  26. // CHECK:STDOUT: }
  27. // CHECK:STDOUT: name_binding_decl {
  28. // CHECK:STDOUT: %x.patt: %struct_type.a.225 = binding_pattern x
  29. // CHECK:STDOUT: %.loc15_1: %struct_type.a.225 = var_pattern %x.patt
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT: %x.var: ref %struct_type.a.225 = var x
  32. // CHECK:STDOUT: %.loc15_15: type = splice_block %struct_type.a [concrete = constants.%struct_type.a.225] {
  33. // CHECK:STDOUT: %.loc15_14.1: %empty_struct_type = struct_literal ()
  34. // CHECK:STDOUT: %.loc15_14.2: type = converted %.loc15_14.1, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  35. // CHECK:STDOUT: %struct_type.a: type = struct_type {.a: %empty_struct_type} [concrete = constants.%struct_type.a.225]
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT: %x: ref %struct_type.a.225 = bind_name x, %x.var
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT:
  40. // CHECK:STDOUT: fn @__global_init() {
  41. // CHECK:STDOUT: !entry:
  42. // CHECK:STDOUT: %.loc15_26: %empty_struct_type = struct_literal ()
  43. // CHECK:STDOUT: %.loc15_27: %struct_type.b = struct_literal (%.loc15_26)
  44. // CHECK:STDOUT: assign file.%x.var, <error>
  45. // CHECK:STDOUT: return
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT: