fail_assign_nested.carbon 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  6. // EXTRA-ARGS: --no-prelude-import --dump-sem-ir-ranges=if-present
  7. //
  8. // AUTOUPDATE
  9. // TIP: To test this file alone, run:
  10. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/struct/fail_assign_nested.carbon
  11. // TIP: To dump output, run:
  12. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/struct/fail_assign_nested.carbon
  13. // CHECK:STDERR: fail_assign_nested.carbon:[[@LINE+4]]:19: error: missing value for field `a` in struct initialization [StructInitMissingFieldInLiteral]
  14. // CHECK:STDERR: var x: {.a: {}} = {.b = {}};
  15. // CHECK:STDERR: ^~~~~~~~~
  16. // CHECK:STDERR:
  17. var x: {.a: {}} = {.b = {}};
  18. // CHECK:STDOUT: --- fail_assign_nested.carbon
  19. // CHECK:STDOUT:
  20. // CHECK:STDOUT: constants {
  21. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  22. // CHECK:STDOUT: %struct_type.a.225: type = struct_type {.a: %empty_struct_type} [concrete]
  23. // CHECK:STDOUT: %pattern_type: type = pattern_type %struct_type.a.225 [concrete]
  24. // CHECK:STDOUT: %struct_type.b: type = struct_type {.b: %empty_struct_type} [concrete]
  25. // CHECK:STDOUT: }
  26. // CHECK:STDOUT:
  27. // CHECK:STDOUT: file {
  28. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  29. // CHECK:STDOUT: .x = %x
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT: name_binding_decl {
  32. // CHECK:STDOUT: %x.patt: %pattern_type = binding_pattern x [concrete]
  33. // CHECK:STDOUT: %x.var_patt: %pattern_type = var_pattern %x.patt [concrete]
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT: %x.var: ref %struct_type.a.225 = var %x.var_patt [concrete]
  36. // CHECK:STDOUT: %.loc18_15: type = splice_block %struct_type.a [concrete = constants.%struct_type.a.225] {
  37. // CHECK:STDOUT: %.loc18_14.1: %empty_struct_type = struct_literal ()
  38. // CHECK:STDOUT: %.loc18_14.2: type = converted %.loc18_14.1, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  39. // CHECK:STDOUT: %struct_type.a: type = struct_type {.a: %empty_struct_type} [concrete = constants.%struct_type.a.225]
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT: %x: ref %struct_type.a.225 = bind_name x, %x.var [concrete = %x.var]
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: fn @__global_init() {
  45. // CHECK:STDOUT: !entry:
  46. // CHECK:STDOUT: %.loc18_26: %empty_struct_type = struct_literal ()
  47. // CHECK:STDOUT: %.loc18_27: %struct_type.b = struct_literal (%.loc18_26)
  48. // CHECK:STDOUT: assign file.%x.var, <error>
  49. // CHECK:STDOUT: return
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT: