fail_assign_nested.carbon 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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+3]]:19: error: missing value for field `a` in struct initialization [StructInitMissingFieldInLiteral]
  11. // CHECK:STDERR: var x: {.a: {}} = {.b = {}};
  12. // CHECK:STDERR: ^~~~~~~~~
  13. var x: {.a: {}} = {.b = {}};
  14. // CHECK:STDOUT: --- fail_assign_nested.carbon
  15. // CHECK:STDOUT:
  16. // CHECK:STDOUT: constants {
  17. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  18. // CHECK:STDOUT: %struct_type.a.225: type = struct_type {.a: %empty_struct_type} [template]
  19. // CHECK:STDOUT: %struct_type.b: type = struct_type {.b: %empty_struct_type} [template]
  20. // CHECK:STDOUT: }
  21. // CHECK:STDOUT:
  22. // CHECK:STDOUT: file {
  23. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  24. // CHECK:STDOUT: .x = %x
  25. // CHECK:STDOUT: }
  26. // CHECK:STDOUT: %x.var: ref %struct_type.a.225 = var x
  27. // CHECK:STDOUT: %x: ref %struct_type.a.225 = bind_name x, %x.var
  28. // CHECK:STDOUT: }
  29. // CHECK:STDOUT:
  30. // CHECK:STDOUT: fn @__global_init() {
  31. // CHECK:STDOUT: !entry:
  32. // CHECK:STDOUT: %.loc14_26: %empty_struct_type = struct_literal ()
  33. // CHECK:STDOUT: %.loc14_27: %struct_type.b = struct_literal (%.loc14_26)
  34. // CHECK:STDOUT: assign file.%x.var, <error>
  35. // CHECK:STDOUT: return
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT: