Repository navigation
Conversation
Converting a string[] with holes into (string | number)[] storage (a spread, a field, an argument, a return value or an assignment of a holey array) aborted with "array index N is a hole", where Node reads the holes as undefined. The width conversion copy now keeps each slot's state: present elements convert, holes stay holes and a present undefined stays undefined at the same index, as the same JS array holds them. The element analysis records the copy's holes and undefined values under the target element ABI wherever an array value is stored at a contextual array type with another element ABI, so reads and iteration of the converted array handle them.
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Comment on lines
+5748
to
+5751
| const target = contextual ? this.mapTypeOf(contextual) : null; | ||
| if (target?.kind !== "array") return []; | ||
| const key = typeKey(target.elem); | ||
| return own.includes(key) ? [] : [key]; |
Contributor
Comment on lines
+120
to
+129
| if (ts.isVariableDeclaration(node) || ts.isPropertyAssignment(node)) convert(node.initializer); | ||
| else if (ts.isShorthandPropertyAssignment(node) && ts.isIdentifier(node.name)) | ||
| convert(node.name); | ||
| else if (ts.isReturnStatement(node)) convert(node.expression); | ||
| else if (ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.EqualsToken) | ||
| convert(node.right); | ||
| else if (ts.isCallExpression(node) || ts.isNewExpression(node)) | ||
| for (const arg of node.arguments?.nodes ?? []) convert(arg); | ||
| return changed; | ||
| } |
Contributor
… copies The width-conversion scan typed every stored value on its own and asked for its contextual type, one checker query per site outside the batched prefetch. It also carried facts into any contextual array type with another element ABI, so the facts an element ABI shares with every array of that ABI widened arrays the copy never reached (the compiler's own IrParam arrays among them). The values the scan compares, and the receivers of their property and element reads, are now typed in the file's batch. The contextual type is asked for only when the value can hold holes or undefined values; an array a call or literal builds counts only its own facts. Facts are carried only where the conversion copies the elements into an array of union elements, whose reads otherwise trap on a hole.
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
string[]into(string | number)[]storage (a spread, a field, an argument, a return value or an assignment) no longer aborts with "array index N is a hole"; the holes read asundefined, as they do in Node.undefinedvalues at their indexes, and the element analysis records them under the target element type, so reads, iteration and the find family of the converted array handle them.