mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 13:40:11 +01:00
Add test for symbolic arguments to templates. (#7736)
Test passing a template argument or a symbolic argument to a template. Fix a bug in the template case where we'd crash when instantiating a dependent discarded expression, because conversion produced an `InstId::None` which the actions machinery did not expect and crashed on.
This commit is contained in:
@@ -1886,7 +1886,7 @@ auto CategoryConverter::DoStep(const SemIR::InstId expr_id,
|
||||
|
||||
if (target_.kind == ConversionTarget::Discarded) {
|
||||
DiscardInitializer(context_, expr_id);
|
||||
return Done{SemIR::InstId::None};
|
||||
return Done{expr_id};
|
||||
} else if (IsValidExprCategoryForConversionTarget(category,
|
||||
target_.kind)) {
|
||||
return Done{expr_id};
|
||||
|
||||
@@ -25,6 +25,32 @@ fn G(x: X) {
|
||||
F(X, x);
|
||||
}
|
||||
|
||||
// --- forward_template_type_to_template.carbon
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
fn F(template T: type, unused x: T) {}
|
||||
|
||||
fn ForwardTemplate(template T: type, x: T) {
|
||||
F(T, x);
|
||||
}
|
||||
|
||||
fn CallForwardTemplate() {
|
||||
ForwardTemplate({}, {});
|
||||
}
|
||||
|
||||
// --- forward_generic_type_to_template.carbon
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
fn F(template T: type, unused x: T) {}
|
||||
|
||||
fn ForwardGeneric(generic T: type, x: T) {
|
||||
F(T, x);
|
||||
}
|
||||
|
||||
fn CallForwardGeneric() {
|
||||
ForwardGeneric({}, {});
|
||||
}
|
||||
|
||||
// --- constant_nontype_argument.carbon
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user