| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- // 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
- //
- // AUTOUPDATE
- // TIP: To test this file alone, run:
- // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/var/no_prelude/fail_init_with_self.carbon
- // TIP: To dump output, run:
- // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/var/no_prelude/fail_init_with_self.carbon
- fn Main() {
- // CHECK:STDERR: fail_init_with_self.carbon:[[@LINE+4]]:15: error: `x` used before initialization [UsedBeforeInitialization]
- // CHECK:STDERR: var x: () = x;
- // CHECK:STDERR: ^
- // CHECK:STDERR:
- var x: () = x;
- }
- // CHECK:STDOUT: --- fail_init_with_self.carbon
- // CHECK:STDOUT:
- // CHECK:STDOUT: constants {
- // CHECK:STDOUT: %Main.type: type = fn_type @Main [template]
- // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
- // CHECK:STDOUT: %Main: %Main.type = struct_value () [template]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = namespace [template] {
- // CHECK:STDOUT: .Main = %Main.decl
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} {}
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @Main() {
- // CHECK:STDOUT: !entry:
- // CHECK:STDOUT: name_binding_decl {
- // CHECK:STDOUT: %x.patt: %empty_tuple.type = binding_pattern x
- // CHECK:STDOUT: %.loc16_3: %empty_tuple.type = var_pattern %x.patt
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %x.var: ref %empty_tuple.type = var x
- // CHECK:STDOUT: %x.ref: <error> = name_ref x, <error> [template = <error>]
- // CHECK:STDOUT: assign %x.var, <error>
- // CHECK:STDOUT: %.loc16_11.1: type = splice_block %.loc16_11.3 [template = constants.%empty_tuple.type] {
- // CHECK:STDOUT: %.loc16_11.2: %empty_tuple.type = tuple_literal ()
- // CHECK:STDOUT: %.loc16_11.3: type = converted %.loc16_11.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %x: ref %empty_tuple.type = bind_name x, %x.var
- // CHECK:STDOUT: return
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
|