| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- // 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
- //
- // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/int.carbon
- // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
- // EXTRA-ARGS: --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/var/fail_storage_is_literal.carbon
- // TIP: To dump output, run:
- // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/var/fail_storage_is_literal.carbon
- fn Main() {
- // CHECK:STDERR: fail_storage_is_literal.carbon:[[@LINE+7]]:10: error: cannot implicitly convert non-type value of type `Core.IntLiteral` to `type` [ConversionFailureNonTypeToFacet]
- // CHECK:STDERR: var x: 1 = 1;
- // CHECK:STDERR: ^
- // CHECK:STDERR: fail_storage_is_literal.carbon:[[@LINE+4]]:10: note: type `Core.IntLiteral` does not implement interface `Core.ImplicitAs(type)` [MissingImplInMemberAccessNote]
- // CHECK:STDERR: var x: 1 = 1;
- // CHECK:STDERR: ^
- // CHECK:STDERR:
- var x: 1 = 1;
- }
- // CHECK:STDOUT: --- fail_storage_is_literal.carbon
- // CHECK:STDOUT:
- // CHECK:STDOUT: constants {
- // CHECK:STDOUT: %Main.type: type = fn_type @Main [concrete]
- // CHECK:STDOUT: %Main: %Main.type = struct_value () [concrete]
- // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete]
- // CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
- // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
- // CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: imports {
- // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
- // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
- // CHECK:STDOUT: .Destroy = %Core.Destroy
- // CHECK:STDOUT: import Core//prelude
- // CHECK:STDOUT: import Core//prelude/...
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/parts/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
- // CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/parts/destroy, Destroy, loaded [concrete = constants.%Destroy.type]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
- // CHECK:STDOUT: .Core = imports.%Core
- // CHECK:STDOUT: .Main = %Main.decl
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %Core.import = import Core
- // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [concrete = constants.%Main] {} {}
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @Main() {
- // CHECK:STDOUT: !entry:
- // CHECK:STDOUT: name_binding_decl {
- // CHECK:STDOUT: %x.patt: <error> = ref_binding_pattern x [concrete]
- // CHECK:STDOUT: %x.var_patt: <error> = var_pattern %x.patt [concrete]
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %x.var: ref <error> = var %x.var_patt [concrete = <error>]
- // CHECK:STDOUT: %int_1.loc23_14: Core.IntLiteral = int_value 1 [concrete = constants.%int_1]
- // CHECK:STDOUT: assign %x.var, <error>
- // CHECK:STDOUT: %.1: <error> = splice_block <error> [concrete = <error>] {
- // CHECK:STDOUT: %int_1.loc23_10: Core.IntLiteral = int_value 1 [concrete = constants.%int_1]
- // CHECK:STDOUT: %.loc23: type = converted %int_1.loc23_10, <error> [concrete = <error>]
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %x: ref <error> = ref_binding x, <error> [concrete = <error>]
- // CHECK:STDOUT: return
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
|