Skip to content

Conversation

danakj
Copy link
Contributor

@danakj danakj commented Jun 23, 2025

If convert fails after applying a substitution in deduce, fail deduction rather than succeeding deduction with an ErrorInst in the deduced argument.

For example, in toolchain/check/testdata/facet/fail_convert_class_type_to_generic_facet_value.carbon the WrongGenericParam is deduced for the first argument, then substituted into the second parameter, but the argument can not convert to the parameter after substitution. In this case, deduction fails instead of producig a call with an error in the second argument. The resulting semir drops the call with an error argument:

-// CHECK:STDOUT:   %CallGenericMethod.specific_fn: <specific function> = specific_function %CallGenericMethod.ref, @CallGenericMethod(constants.%WrongGenericParam, <error>) [concrete = <error>]
-// CHECK:STDOUT:   %CallGenericMethod.call: init %empty_tuple.type = call %CallGenericMethod.specific_fn() [concrete = <error>]

@github-actions github-actions bot requested a review from jonmeow June 23, 2025 17:20
@danakj danakj changed the title Avoid deducing errors when substing specifics or deduced args into further parameters Avoid deducing errors as argument instructions after subst Jun 23, 2025
Copy link
Contributor

@jonmeow jonmeow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG

@jonmeow jonmeow added this pull request to the merge queue Jun 23, 2025
Merged via the queue into carbon-language:trunk with commit ad4914b Jun 23, 2025
10 checks passed
@danakj danakj deleted the deduce-error branch June 24, 2025 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants