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

Unified Diff: pkg/front_end/lib/src/fasta/source/outline_builder.dart

Issue 2782843002: Complain about bad operator parameters. (Closed)
Patch Set: Created 3 years, 9 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
Index: pkg/front_end/lib/src/fasta/source/outline_builder.dart
diff --git a/pkg/front_end/lib/src/fasta/source/outline_builder.dart b/pkg/front_end/lib/src/fasta/source/outline_builder.dart
index 81ef39e4b7e7d0a99ddf07bd93747b789d9c45b9..20d32895ba10359a672b3190ee49a5e50c50c949 100644
--- a/pkg/front_end/lib/src/fasta/source/outline_builder.dart
+++ b/pkg/front_end/lib/src/fasta/source/outline_builder.dart
@@ -31,7 +31,12 @@ import 'unhandled_listener.dart' show NullValue, Unhandled, UnhandledListener;
import '../parser/dart_vm_native.dart'
show removeNativeClause, skipNativeClause;
-import '../operator.dart' show Operator, operatorFromString, operatorToString;
+import '../operator.dart'
+ show
+ Operator,
+ operatorFromString,
+ operatorToString,
+ operatorRequiredArgumentCount;
import '../quote.dart' show unescapeString;
@@ -369,6 +374,22 @@ class OutlineBuilder extends UnhandledListener {
if (nameOrOperator is Operator) {
name = operatorToString(nameOrOperator);
kind = ProcedureKind.Operator;
+ int requiredArgumentCount = operatorRequiredArgumentCount(nameOrOperator);
+ if ((formals?.length ?? 0) != requiredArgumentCount) {
+ library.addCompileTimeError(
+ charOffset,
+ "Operator '$name' must have exactly $requiredArgumentCount "
+ "parameters.");
+ } else {
+ if (formals != null) {
+ for (FormalParameterBuilder formal in formals) {
+ if (!formal.isRequired) {
+ library.addCompileTimeError(formal.charOffset,
+ "An operator can't have optional parameters.");
+ }
+ }
+ }
+ }
} else {
name = nameOrOperator;
kind = computeProcedureKind(getOrSet);

Powered by Google App Engine
This is Rietveld 408576698