Files
carbon-lang/toolchain/check/testdata/deduce/symbolic_facets.carbon
T
Hitesh JoshiandHitesh Joshi 0166d8837c Update Documentation to use new expression terminology (#5890)
# Changes

## Terminology Updates
This PR updates documentation to align with the expression phase
terminology changes introduced in
[#2964](https://github.com/carbon-language/carbon-lang/pull/2964):

* **"symbolic value" → "symbolic constant"**: Updated all remaining
instances using find-and-replace

## Scope of Changes
* Focused on documentation that predates the July 2023 terminology
change
* Used git blame history to identify instances likely using the old
"constant" definition
* Manually reviewed each "constant" usage to distinguish between:
- New definition (unchanged): the broader category including symbolic
constants

Closes
[#5599](https://github.com/carbon-language/carbon-lang/issues/5599)

---------

Co-authored-by: Hitesh Joshi <hitesh@mitsu.care>
2025-09-30 20:15:55 +00:00

82 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
//
// 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/symbolic_facets.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/deduce/symbolic_facets.carbon
// By placing each interface inside a generic class, a facet type refering to
// the interface becomes symbolic. Normally they would be concrete. This can
// affect decisions in deduce which unwraps symbolic constants, but still needs to
// ensure they convert correctly.
// --- fail_missing_interface.carbon
library "[[@TEST_NAME]]";
class C(CC:! type) {
interface A {}
fn F(T:! A) {}
}
class D(DD:! type) {
interface B {}
fn G(T:! B) {
// T only implements D(DD).B, so should not convert to a facet value
// implementing C(()).A.
//
// CHECK:STDERR: fail_missing_interface.carbon:[[@LINE+7]]:5: error: cannot convert type `T` that implements `B` into type implementing `A` [ConversionFailureFacetToFacet]
// CHECK:STDERR: C(()).F(T);
// CHECK:STDERR: ^~~~~~~~~~
// CHECK:STDERR: fail_missing_interface.carbon:[[@LINE-12]]:3: note: while deducing parameters of generic declared here [DeductionGenericHere]
// CHECK:STDERR: fn F(T:! A) {}
// CHECK:STDERR: ^~~~~~~~~~~~~
// CHECK:STDERR:
C(()).F(T);
}
}
// --- fail_interface_wrong_generic_param.carbon
library "[[@TEST_NAME]]";
class C(CC:! type) {
interface A {}
fn F(T:! A) {}
}
class D(DD:! type) {
interface B {}
fn G(T:! B & C({}).A) {
// T implements C({}).A and D(DD).B, so should not convert to a facet value
// implementing C(()).A.
//
// CHECK:STDERR: fail_interface_wrong_generic_param.carbon:[[@LINE+7]]:5: error: cannot convert type `T` that implements `A & B` into type implementing `A` [ConversionFailureFacetToFacet]
// CHECK:STDERR: C(()).F(T);
// CHECK:STDERR: ^~~~~~~~~~
// CHECK:STDERR: fail_interface_wrong_generic_param.carbon:[[@LINE-12]]:3: note: while deducing parameters of generic declared here [DeductionGenericHere]
// CHECK:STDERR: fn F(T:! A) {}
// CHECK:STDERR: ^~~~~~~~~~~~~
// CHECK:STDERR:
C(()).F(T);
}
}
// --- compatible_deduce.carbon
library "[[@TEST_NAME]]";
class C(CC:! type) {
interface A {}
fn F(T:! A) {}
}
class D(DD:! type) {
interface B {}
fn G(T:! B & C(()).A) {
C(()).F(T);
}
}