Files
carbon-lang/toolchain/check/testdata/where_expr/subst.carbon
T
Richard SmithandDana Jansens 643ab57f5a Refactor CppRange interface and fix a crash exposed by doing so. (#7515)
Split up the CppRange interface into smaller parts, with the intent of
improving the diagnostic quality and making the implementation easier to
understand.

This also makes the implementation details of the CppRange machinery
private, which breaks one of the existing tests; that test is split into
two files, one which tests the low-level machinery works, and another
that tests the resulting prelude behavior.

This change exposes a crash in `where` expression handling, where we
would perform a substitution that creates a new `SpecificConstant` that
refers into a region of a generic that has never been resolved. Fix that
by resolving the definition region of a generic if eval sees a
`SpecificConstant` that refers into it. This is usually not necessary
because something else should have resolved that region first, but that
doesn't happen here.

---------

Co-authored-by: Dana Jansens <danakj@orodu.net>
2026-07-17 00:31:12 +00:00

31 lines
1.2 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/int.carbon
//
// AUTOUPDATE
// TIP: To test this file alone, run:
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/where_expr/subst.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/where_expr/subst.carbon
// --- subst_into_named_constraint.carbon
library "[[@TEST_NAME]]";
interface A { let T: type; }
constraint B {
require impls A;
alias U = Self.(A.T);
}
// When type-checking this, we will thaw the `.Self` in the `.U = ()`
// constraint. That performs a substitution of a SpecificConstant that refers
// into the definition region of constraint B's NamedConstraintWithSelf generic.
// For this to work, we need to resolve the definition region of that specific
// as part of the substitution process.
fn F(generic _: B where .U = ()) {}
class C { impl as A where .T = () {} }
fn Test() { F(C); }