remove allowMetaTypes for inferStaticParam + properly annotate unresolved range #24086
+33
−9
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.
fixes #19923
The code in #19923 already compiles since #24005, but when actually trying to pass an argument to it,
sigmatch
fails to infer thearray
type (but does infer the range type). There are 2 reasons:self.S * 8
is atyFromExpr
which for some reason results in the range type not being markedtfUnresolved
, and so array types just test for range span equality. This is becausemakeRangeWithStaticExpr
only setstfUnresolved
if the given expression type isn't nil and has a nil node which is never true fortyFromExpr
. This is fixed by just manually settingtfUnresolved
. (also for when the nodehasUnresolvedArgs
but this isn't necessary here)self.S
at overload resolution time sinceinferStaticParam
enablesallowMetaTypes
, which results intyFromExpr
s never getting instantiated. To fix this we turn offallowMetaTypes
.Turning off
allowMetaTypes
here has several consequences:instCopyType
which changes their ID, so to give their bindings properly we have to get the original static type ID, which is done here by doing.sym.typ
on the static type, since thesym
is invariant between type copies. Thankfully onlyinferStaticParam
gives a binding here.semtypinst
and the call tofailureToInferStaticParam
. In practice this isn't encountered often (mostly because it wasn't possible before) but it can cause unrelated overloads to be inaccessible if an overload requires explicit generic arguments. If this becomes a problem we can refactorsemtypinst
andfailureToInferStaticParam
to a version that just doesn't globally error on these and passes the information to the mismatch errors. Edit: Done in consider instantiation errors in overload resolution as type mismatch #24098