5516802142
From G3 bug ID: 116443331 The View Engine compiler crashes when it tries to compile a test in JIT mode that includes the d3-scale-chromatic library [1]. The d3 package initializes some arrays using the following pattern: ```js export var scheme = new Array(3).concat( "d8b365f5f5f55ab4ac", // ... more entries ).map(colors); ``` The stack trace from the crash is as follows: ``` TypeError: Cannot read property 'visitExpression' of undefined at ../../../third_party/javascript/angular2/rc/packages/compiler/src/output/abstract_emitter.ts:505:39 at JitEmitterVisitor.AbstractEmitterVisitor.visitAllObjects third_party/javascript/angular2/rc/packages/compiler/src/output/abstract_emitter.ts?l=526 at JitEmitterVisitor.AbstractEmitterVisitor.visitAllExpressions third_party/javascript/angular2/rc/packages/compiler/src/output/abstract_emitter.ts?l=505 at JitEmitterVisitor.AbstractEmitterVisitor.visitLiteralArrayExpr third_party/javascript/angular2/rc/packages/compiler/src/output/abstract_emitter.ts?l=484 at LiteralArrayExpr.visitExpression third_party/javascript/angular2/rc/packages/compiler/src/output/output_ast.ts?l=791 at ../../../third_party/javascript/angular2/rc/packages/compiler/src/output/abstract_emitter.ts:492:19 at JitEmitterVisitor.AbstractEmitterVisitor.visitAllObjects third_party/javascript/angular2/rc/packages/compiler/src/output/abstract_emitter.ts?l=526 at JitEmitterVisitor.AbstractEmitterVisitor.visitLiteralMapExpr third_party/javascript/angular2/rc/packages/compiler/src/output/abstract_emitter.ts?l=490 at LiteralMapExpr.visitExpression third_party/javascript/angular2/rc/packages/compiler/src/output/output_ast.ts?l=819 at ../../../third_party/javascript/angular2/rc/packages/compiler/src/output/abstract_emitter.ts:505:39 at JitEmitterVisitor.AbstractEmitterVisitor.visitAllObjects third_party/javascript/angular2/rc/packages/compiler/src/output/abstract_emitter.ts?l=526 at JitEmitterVisitor.AbstractEmitterVisitor.visitAllExpressions third_party/javascript/angular2/rc/packages/compiler/src/output/abstract_emitter.ts?l=505 at JitEmitterVisitor.AbstractEmitterVisitor.visitInvokeFunctionExpr third_party/javascript/angular2/rc/packages/compiler/src/output/abstract_emitter.ts?l=318 at JitEmitterVisitor.AbstractJsEmitterVisitor.visitInvokeFunctionExpr third_party/javascript/angular2/rc/packages/compiler/src/output/abstract_js_emitter.ts?l=112 at InvokeFunctionExpr.visitExpression third_party/javascript/angular2/rc/packages/compiler/src/output/output_ast.ts?l=440 ``` This is because the corresponding output AST for the array is of the form ```ts [ undefined, undefined, undefined, o.LiteralExpr, // ... ] ``` The output AST is clearly malformed and breaks the type representation of `LiteralArrayExpr` in which every entry is expected to be of type `Expression`. This commit fixes the bug by using a plain `for` loop to iterate over the entire length of the holey array and convert undefined elements to `LiteralExpr`. [1]: https://github.com/d3/d3-scale-chromatic/blob/master/src/diverging/BrBG.js PR Close #36343 |
||
---|---|---|
.. | ||
abstract_emitter_node_only_spec.ts | ||
abstract_emitter_spec.ts | ||
js_emitter_node_only_spec.ts | ||
js_emitter_spec.ts | ||
output_ast_spec.ts | ||
output_jit_spec.ts | ||
source_map_spec.ts | ||
ts_emitter_node_only_spec.ts | ||
ts_emitter_spec.ts | ||
value_util_spec.ts |