Fix parser to generate error when array has more than 32 dimensions#16276
Fix parser to generate error when array has more than 32 dimensions#16276iSazonov merged 2 commits intoPowerShell:masterfrom
Conversation
|
|
||
| // The dimensions for an array must be less than or equal to 32. | ||
| // Search the doc for 'Type.MakeArrayType(int rank)' for more details. | ||
| if (dim > 32) |
There was a problem hiding this comment.
Would we get better UX in PSRL if we move the error report in cycle above?
There was a problem hiding this comment.
Hmm. We'd need to be very careful to ensure we continue to consume , tokens until we hit a ] or something unexpected if we want to do that.
This way is a bit simpler to follow, and I think the only UX difference we'd really get would be that maybe we'd be able to pinpoint exactly the point at which there are too many commas, rather than reporting an error for the whole type token.
I don't know if that really gives much to aid the user, though.
There was a problem hiding this comment.
There is no difference in UX in PSRL. PSRL will just change the last token of the user prompt to red color (not always, depending on the user's custom prompt function) in the event of a parsing error.
maybe we'd be able to pinpoint exactly the point at which there are too many commas, rather than reporting an error for the whole type token.
I think it's clearer to give user the exact number of dimensions the array is declared with. Moving the error report in the loop will only detect that it's more than 32 now, but won't get you the exact number of dimensions.
|
@iSazonov I removed the |
|
@iSazonov I think you can merge this one now. |
|
🎉 Handy links: |
…owerShell#16276) An array cannot have more than 32 dimensions. See the doc of MarkArrayType(int rank)) https://docs.microsoft.com/en-us/dotnet/api/system.type.makearraytype?view=net-5.0#System_Type_MakeArrayType_System_Int32_ for details. The fix is to not create the ArrayTypeName instance when the number of dimensions exceeds 32, but instead, generate a parsing error.
PR Summary
Fix #16275
An array cannot have more than 32 dimensions. See the doc of MarkArrayType(int rank)) for details.
The fix is to not create the
ArrayTypeNameinstance when the number of dimensions exceeds 32, but instead, generate a parsing error.PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.