add some type info to Base to avoid excess recursion in inference #33476
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 #33336.
This addresses some commonly-occurring cases where having too little type info makes inference see a lot of recursion in Base that is not actually possible.
Of course, this is not satisfying, since these are empirically determined (*). @vtjnash & I would also like to make inference's cycle handling smarter, but that will be a longer project.
Needs review from @mbauman : Are the dataid arguments to
_isdisjoint
indeed alwaysUInt
? And is it safe to assume that the length of an index in broadcast is anInteger
?(*) Methodology is as follows:
Apply this patch:
(you will also need to add
const trace_inf = [false]
somewhere. SetCore.Compiler.trace_inf[]=true
just before running the problematic call. In the output, look for calls from simple "innocent" Base functions that lead into package code or big nests of code like broadcast, that they should not be able to touch. For example:There,
fill_to_length
, a low-level tuple utility, led to inference of>(Int64, MDDatasets.DataMD)
which then calls broadcast, etc. That can be patched up by declaring the second argument to>
infill_to_length
asInt
(which it will always be, but inference can't tell).