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

Unified Diff: runtime/lib/errors_patch.dart

Issue 177633008: Better error message for assignment to final local variables (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 10 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 | runtime/lib/invocation_mirror.h » ('j') | runtime/vm/parser.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/errors_patch.dart
===================================================================
--- runtime/lib/errors_patch.dart (revision 32974)
+++ runtime/lib/errors_patch.dart (working copy)
@@ -212,11 +212,15 @@
var level = (_invocation_type >> _InvocationMirror._CALL_SHIFT) &
_InvocationMirror._CALL_MASK;
var type_str =
- (const ["method", "getter", "setter", "getter or setter"])[type];
+ (const ["method", "getter", "setter", "getter or setter", "variable"])[type];
var args_message = args_mismatch ? " with matching arguments" : "";
var msg;
var memberName =
(_memberName == null) ? "" : internal.Symbol.getName(_memberName);
+
+ if (type == _InvocationMirror._LOCAL_VAR) {
+ return "cannot assign to final variable '$memberName'.\n\n";
Ivan Posva 2014/02/25 07:10:07 How about just assigning to msg here and let the r
hausner 2014/02/25 18:47:05 I'm not sure what massaging you mean. Adding the t
+ }
switch (level) {
case _InvocationMirror._DYNAMIC: {
if (_receiver == null) {
@@ -294,9 +298,13 @@
}
var memberName =
(_memberName == null) ? "" : internal.Symbol.getName(_memberName);
- if (!args_mismatch) {
+ var type = _invocation_type & _InvocationMirror._TYPE_MASK;
+ if (type == _InvocationMirror._LOCAL_VAR) {
msg_buf.write(
- "NoSuchMethodError : method not found: '$memberName'\n"
+ "NoSuchMethodError: cannot assign to final variable '$memberName'");
+ } else if (!args_mismatch) {
+ msg_buf.write(
+ "NoSuchMethodError: method not found: '$memberName'\n"
"Receiver: $receiver_str\n"
"Arguments: [$actual_buf]");
} else {
« no previous file with comments | « no previous file | runtime/lib/invocation_mirror.h » ('j') | runtime/vm/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698