Fix type inference for slicing in some cases #422
Merged
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.
In some cases, the compiler does not infer a dimension type for a sliced array. (It says "multiple applicable items in scope" when calling
.dot()
on the sliced array.) See thetest_slice_infer
test in this PR.A partial fix is to implement
SliceNextDim
for moreRange*
types. I'm not quite sure why this works, and inference is still broken for integers that aren't part of ranges (the commented-out line intest_slice_infer
), but it's an improvement.It's worth noting that I also tried implementing
SliceNextDim
forRange*<u8>
,Range*<u16>
, … (all primitive integer types) instead ofRange*<T>
whereT: PrimInt
, but that didn't fix the issue.I've tried fixing inference for integers that aren't part of ranges, but I haven't had any success. Some of the things I've tried:
SliceNextDim
foru8
,u16
, … (all primitive integer types), but that didn't fix the issue.D2
generic type parameter inSliceNextDim<D1, D2>
to an associated type. I think that's a better design anyway (and I'll create a PR for this later since it's a breaking change), but it didn't fix this issue.SliceNextDimInner<D>
and then implementingSliceNextDim
forT: SliceNextDimInner<D>
, but that didn't fix the issue.Does anyone have suggestions for fixing inference with integers that aren't part of ranges?