/
githubmirror
/
carbon-lang
Обзор
Документация
Войти
/
githubmirror
/
carbon-lang
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
toolchain/check/testdata/deduce/binding_pattern.carbon
62 строки
2 KB
Chandler Carruth
Replace `:!` binding syntax with phase keywords and contextual defaults (#7479)
11 июл 2026, 04:22
Не верифицирован
11 июл 2026, 04:22
8be274c
Код
Авторство
О чём код?
// 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/convert.carbon // // AUTOUPDATE // TIP: To test this file alone, run: // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/deduce/binding_pattern.carbon // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/deduce/binding_pattern.carbon // --- fail_incompatible_deduce.carbon library "[[@TEST_NAME]]"; class C(T: type) { fn Create(unused value: T) {} } fn F(unused generic U: type, generic V: type) { // CHECK:STDERR: fail_incompatible_deduce.carbon:[[@LINE+10]]:15: error: cannot implicitly convert expression of type `{}` to `V` [ConversionFailure] // CHECK:STDERR: C(V).Create({}); // CHECK:STDERR: ^~ // CHECK:STDERR: fail_incompatible_deduce.carbon:[[@LINE+7]]:15: note: type `{}` does not implement interface `Core.ImplicitAs(V)` [MissingImplInMemberAccessInContext] // CHECK:STDERR: C(V).Create({}); // CHECK:STDERR: ^~ // CHECK:STDERR: fail_incompatible_deduce.carbon:[[@LINE-10]]:20: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: fn Create(unused value: T) {} // CHECK:STDERR: ^~~~~~~~ // CHECK:STDERR: C(V).Create({}); } // --- compatible_deduce.carbon library "[[@TEST_NAME]]"; class C(T: type) { fn Create(unused value: T) {} } // This `where` is sufficient to say that `{} as V` works. fn F(unused generic U: type, generic V: Core.Destroy where {} impls Core.ImplicitAs(.Self)) { C(V).Create({}); } // --- fail_invalid_type.carbon library "[[@TEST_NAME]]"; class A {}; // CHECK:STDERR: fail_invalid_type.carbon:[[@LINE+4]]:9: error: name `DoesNotExist` not found [NameNotFound] // CHECK:STDERR: fn F[T: DoesNotExist](unused x: T) {} // CHECK:STDERR: ^~~~~~~~~~~~ // CHECK:STDERR: fn F[T: DoesNotExist](unused x: T) {} fn Call(a: A) { F(a); }