From ece7725d902b446469fe67ad96f9199543fe504a Mon Sep 17 00:00:00 2001 From: Stephen Adams Date: Wed, 30 Nov 2016 16:52:07 -0800 Subject: [PATCH] dart2js-kernel: Emit error trap for unimplemented features MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test will fail with an error like the following, rather than proceed with an incorrect null value. R=efortuna@google.com Review URL: https://codereview.chromium.org/2540363002 . TypeError: Cannot read property 'Unhandled ir.FunctionExpression (dynamic x) → dynamic => x' of null --- pkg/compiler/lib/src/ssa/builder_kernel.dart | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pkg/compiler/lib/src/ssa/builder_kernel.dart b/pkg/compiler/lib/src/ssa/builder_kernel.dart index 4c3e52956ef..b84d1ad4400 100644 --- a/pkg/compiler/lib/src/ssa/builder_kernel.dart +++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart @@ -380,8 +380,17 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder { @override void defaultExpression(ir.Expression expression) { - // TODO(het): This is only to get tests working - stack.add(graph.addConstantNull(compiler)); + // TODO(het): This is only to get tests working. + String message = 'Unhandled ir.${expression.runtimeType} $expression'; + HInstruction nullValue = graph.addConstantNull(compiler); + HInstruction errorMessage = + graph.addConstantString(new DartString.literal(message), compiler); + HInstruction trap = new HForeignCode( + js.js.parseForeignJS("#.#"), + backend.dynamicType, + [nullValue, errorMessage]); + trap.sideEffects..setAllSideEffects()..setDependsOnSomething(); + push(trap); } /// Returns the current source element.