mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
People seemed receptive [on #toolchain](https://discord.com/channels/655572317891461132/655578254970716160/1379196447827689553), so proceeding. For the two name conflicts, I've set it up so that there's a "foo.carbon" and "foo_with_prelude.carbon", to indicate that the no-prelude approach is preferred (with a shorter name). Note min_prelude will require a little more work/thought, I want to avoid adding `--custom-core` etc.
54 lines
2.7 KiB
Plaintext
54 lines
2.7 KiB
Plaintext
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
// TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
|
|
// EXTRA-ARGS: --no-prelude-import --dump-sem-ir-ranges=if-present
|
|
//
|
|
// AUTOUPDATE
|
|
// TIP: To test this file alone, run:
|
|
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/struct/fail_assign_nested.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/struct/fail_assign_nested.carbon
|
|
|
|
// CHECK:STDERR: fail_assign_nested.carbon:[[@LINE+4]]:19: error: missing value for field `a` in struct initialization [StructInitMissingFieldInLiteral]
|
|
// CHECK:STDERR: var x: {.a: {}} = {.b = {}};
|
|
// CHECK:STDERR: ^~~~~~~~~
|
|
// CHECK:STDERR:
|
|
var x: {.a: {}} = {.b = {}};
|
|
|
|
// CHECK:STDOUT: --- fail_assign_nested.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
|
|
// CHECK:STDOUT: %struct_type.a.225: type = struct_type {.a: %empty_struct_type} [concrete]
|
|
// CHECK:STDOUT: %pattern_type: type = pattern_type %struct_type.a.225 [concrete]
|
|
// CHECK:STDOUT: %struct_type.b: type = struct_type {.b: %empty_struct_type} [concrete]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
|
|
// CHECK:STDOUT: .x = %x
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: name_binding_decl {
|
|
// CHECK:STDOUT: %x.patt: %pattern_type = binding_pattern x [concrete]
|
|
// CHECK:STDOUT: %x.var_patt: %pattern_type = var_pattern %x.patt [concrete]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %x.var: ref %struct_type.a.225 = var %x.var_patt [concrete]
|
|
// CHECK:STDOUT: %.loc18_15: type = splice_block %struct_type.a [concrete = constants.%struct_type.a.225] {
|
|
// CHECK:STDOUT: %.loc18_14.1: %empty_struct_type = struct_literal ()
|
|
// CHECK:STDOUT: %.loc18_14.2: type = converted %.loc18_14.1, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
|
|
// CHECK:STDOUT: %struct_type.a: type = struct_type {.a: %empty_struct_type} [concrete = constants.%struct_type.a.225]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %x: ref %struct_type.a.225 = bind_name x, %x.var [concrete = %x.var]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @__global_init() {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %.loc18_26: %empty_struct_type = struct_literal ()
|
|
// CHECK:STDOUT: %.loc18_27: %struct_type.b = struct_literal (%.loc18_26)
|
|
// CHECK:STDOUT: assign file.%x.var, <error>
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|