Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Unified Diff: pkg/compiler/lib/src/ssa/builder.dart

Issue 1353243002: Nicer error for JS() form with mismatched arguments. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/ssa/builder.dart
diff --git a/pkg/compiler/lib/src/ssa/builder.dart b/pkg/compiler/lib/src/ssa/builder.dart
index dea6da6f8cc2a35a6ed92750e30cb16b8b7fcd57..a853635da6671b0f4995458fbbcbc257becca448 100644
--- a/pkg/compiler/lib/src/ssa/builder.dart
+++ b/pkg/compiler/lib/src/ssa/builder.dart
@@ -4074,6 +4074,7 @@ class SsaBuilder extends ast.Visitor
// Don't visit the first argument, which is the type, and the second
// argument, which is the foreign code.
if (link.isEmpty || link.tail.isEmpty) {
+ // We should not get here because the call should be compiled to NSM.
compiler.internalError(node.argumentsNode,
'At least two arguments expected.');
}
@@ -4083,6 +4084,16 @@ class SsaBuilder extends ast.Visitor
List<HInstruction> inputs = <HInstruction>[];
addGenericSendArgumentsToList(link.tail.tail, inputs);
+ if (nativeBehavior.codeTemplate.positionalArgumentCount != inputs.length) {
+ compiler.reportError(
+ node, MessageKind.GENERIC,
+ {'text':
+ 'Mismatch between number of placeholders'
+ ' and number of arguments.'});
+ stack.add(graph.addConstantNull(compiler)); // Result expected on stack.
+ return;
+ }
+
TypeMask ssaType =
TypeMaskFactory.fromNativeBehavior(nativeBehavior, compiler);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698