Specfiy root expression from type specifying extensions #1516
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a follow-up of the introduction of the root expression feature #1254
And it improves the
StrContainingTypeSpecifyingExtension
, the only extension where we currently make use of aFAUX_FUNCTION
#1068 to specify additional infos we cannot model with the type system (in case ofstr_contains
that e.g. "foo" is inside some string, which we specify a non-empty-string).UPDATE: this was a bit weirder than I thought at first to adapt because the extension supports functions that evaluate to a boolean and also others that don't and cannot be supported by what this PR adds.
The idea behind this PR is that if extensions specify a root expression, that resolves to a
BooleanType
(which theImpossibleCheckTypeHelper
basically ignores now to avoid false positives), we can specify that asConstantBooleanType(true)
. This includes the previously mentionedFAUX_FUNCTION
that is used to make the TypeSpecifier aware of the additional unknown info. What this effectively does is, whenever the exact same expression, with the exact sameFAUX_FUNCTION
is resolved again, it resolves totrue
and produces an impossible type error.That means that we can now detect cases where calls with the exact same "unknown information" were made multiple times.
This also helps me simplify the logic I want to add to the webmozart-assert extension to specify various
non-empty-string
assertions without missing those impossible types :) In case this generic adaption does not make much sense, I guess I'd only specify those types in the webmozart-assert extension which is also fine.