fail_assign_to_empty.carbon 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. // CHECK:STDERR: fail_assign_to_empty.carbon:[[@LINE+3]]:13: ERROR: Cannot initialize struct with 0 field(s) from struct with 1 field(s).
  7. // CHECK:STDERR: var x: {} = {.a = 1};
  8. // CHECK:STDERR: ^~~~~~~~
  9. var x: {} = {.a = 1};
  10. // CHECK:STDOUT: --- fail_assign_to_empty.carbon
  11. // CHECK:STDOUT:
  12. // CHECK:STDOUT: constants {
  13. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  14. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  15. // CHECK:STDOUT: %.3: i32 = int_literal 1 [template]
  16. // CHECK:STDOUT: %.4: type = struct_type {.a: i32} [template]
  17. // CHECK:STDOUT: }
  18. // CHECK:STDOUT:
  19. // CHECK:STDOUT: file {
  20. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  21. // CHECK:STDOUT: .Core = %Core
  22. // CHECK:STDOUT: .x = %x
  23. // CHECK:STDOUT: }
  24. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  25. // CHECK:STDOUT: %.loc10_9.1: {} = struct_literal ()
  26. // CHECK:STDOUT: %.loc10_9.2: type = converted %.loc10_9.1, constants.%.1 [template = constants.%.1]
  27. // CHECK:STDOUT: %x.var: ref {} = var x
  28. // CHECK:STDOUT: %x: ref {} = bind_name x, %x.var
  29. // CHECK:STDOUT: }
  30. // CHECK:STDOUT:
  31. // CHECK:STDOUT: fn @__global_init() {
  32. // CHECK:STDOUT: !entry:
  33. // CHECK:STDOUT: %.loc10_19: i32 = int_literal 1 [template = constants.%.3]
  34. // CHECK:STDOUT: %.loc10_20: {.a: i32} = struct_literal (%.loc10_19)
  35. // CHECK:STDOUT: assign file.%x.var, <error>
  36. // CHECK:STDOUT: return
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: