-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve NTuple show and cleanup code for Vararg and NTuple type parameter construction #51244
Conversation
Is it possible to only apply this fix to method signature? |
The PR currently only addresses Vararg. I tried looking into restricting NTuple but not Tuple, but that didn't work out (see the edit above), so nothing should change wrt. Tuple behavior for now. |
Current status of the testsuite with this added restriction looks like: This can be fixed in Test:
This is a failure of inference, due to failure to evaluate
These ones we meant to break here:
|
I fixed those. |
@nanosoldier |
The package evaluation job you requested has completed - possible new issues were detected. |
Ah, right, this approach will probably never work, since StaticArrays assumes this is valid to use to represent array dimension tuples. For example, an |
We're only disallowing I guess it doesn't make sense to disallow |
@nanosoldier |
The package evaluation job you requested has completed - possible new issues were detected. |
OK, that didn't work because Working around this now by special-casing the Vararg handling when contained in a NTuple (by temporarily swapping in a valid type for T, which is a hack, but we cannot simply disable |
@nanosoldier |
The package evaluation job you requested has completed - possible new issues were detected. |
@nanosoldier |
The package evaluation job you requested has completed - possible new issues were detected. |
f793245
to
4e66163
Compare
I have moved the minimal bugfix to #51300 instead, and kept this PR as just the code cleanups. It also now implements a better |
Various simplifications and improvements from investigating #51228. Improves the logic for showing of NTuple to handle constant lengths. Improves the logic for showing NTuple of bound length (e.g. NTuple itself). Also makes a choice to avoid showing non-types as NTuple, but instead try to write them out, to make it more visually obvious when the parameters have been swapped.
Refs #51228
@vtjnash Why did you mention that the printing of NTuple needs to be adjusted? Your example still works fine:
... even though I guess the same validation could happen for NTuple, especially because it's just a Vararg:
EDIT: AFAICT, it doesn't seem as easy to reject
NTuple{1,2}
, because instantiation happens in two steps: First,inst_tuple_w_
instantiates this to a fixed-length tuple, but the invalidT=2
doesn't seem known there (there's onlyT=T
andN=1
in the type environment). Then,inst_datatype_inner
instantiates the Tuple, but we can't rejectT=2
there asTuple{2}
is valid.