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

Issue 10905109: Add named constructor name checking (Closed)

Created:
8 years, 3 months ago by hausner
Modified:
8 years, 3 months ago
Reviewers:
ahe, siva, Ivan Posva
CC:
reviews_dartlang.org, Ivan Posva, kasperl, ahe
Visibility:
Public.

Description

Add named constructor name checking Named constructors may not clash with any other class members. Add a check but enable it only when --construcotr_name_check runtime flag is passed to the VM. Eliminate one named constructor in Process class in core library, as well as a couple of cases in dart2js. The dart2js team may want to rename the constructors I changed. Issue 3990 (http://code.google.com/p/dart/issues/detail?id=3990) Committed: https://code.google.com/p/dart/source/detail?r=11972

Patch Set 1 #

Patch Set 2 : #

Total comments: 9

Patch Set 3 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+42 lines, -19 lines) Patch
M pkg/dartdoc/ast.dart View 1 2 1 chunk +1 line, -1 line 0 comments Download
M runtime/bin/process.dart View 1 2 1 chunk +1 line, -1 line 0 comments Download
M runtime/bin/process_impl.dart View 1 2 1 chunk +0 lines, -6 lines 0 comments Download
M runtime/vm/parser.h View 1 2 1 chunk +1 line, -1 line 0 comments Download
M runtime/vm/parser.cc View 1 2 7 chunks +26 lines, -7 lines 0 comments Download
M tests/language/bad_constructor_test.dart View 1 2 2 chunks +11 lines, -1 line 0 comments Download
M tests/language/function_literals2_test.dart View 1 2 2 chunks +2 lines, -2 lines 0 comments Download

Messages

Total messages: 9 (0 generated)
hausner
I propose to send out a BREAKING CHANGE message soon and then enable the check ...
8 years, 3 months ago (2012-09-05 21:50:51 UTC) #1
hausner
Updated changelist. Turns out Kasper already fixed the dart2js problem.
8 years, 3 months ago (2012-09-05 22:09:09 UTC) #2
ahe
LGTM http://codereview.chromium.org/10905109/diff/4001/tests/language/bad_constructor_test.dart File tests/language/bad_constructor_test.dart (right): http://codereview.chromium.org/10905109/diff/4001/tests/language/bad_constructor_test.dart#newcode4 tests/language/bad_constructor_test.dart:4: // VMOptions=--constructor_name_check Please don't add VM specific options ...
8 years, 3 months ago (2012-09-06 08:54:26 UTC) #3
Ivan Posva
LGTM -Ivan http://codereview.chromium.org/10905109/diff/4001/tests/language/bad_constructor_test.dart File tests/language/bad_constructor_test.dart (right): http://codereview.chromium.org/10905109/diff/4001/tests/language/bad_constructor_test.dart#newcode4 tests/language/bad_constructor_test.dart:4: // VMOptions=--constructor_name_check On 2012/09/06 08:54:26, ahe wrote: ...
8 years, 3 months ago (2012-09-06 09:12:50 UTC) #4
ahe
http://codereview.chromium.org/10905109/diff/4001/tests/language/bad_constructor_test.dart File tests/language/bad_constructor_test.dart (right): http://codereview.chromium.org/10905109/diff/4001/tests/language/bad_constructor_test.dart#newcode4 tests/language/bad_constructor_test.dart:4: // VMOptions=--constructor_name_check On 2012/09/06 09:12:50, Ivan Posva wrote: > ...
8 years, 3 months ago (2012-09-06 09:32:59 UTC) #5
Ivan Posva
http://codereview.chromium.org/10905109/diff/4001/tests/language/bad_constructor_test.dart File tests/language/bad_constructor_test.dart (right): http://codereview.chromium.org/10905109/diff/4001/tests/language/bad_constructor_test.dart#newcode4 tests/language/bad_constructor_test.dart:4: // VMOptions=--constructor_name_check On 2012/09/06 09:32:59, ahe wrote: > On ...
8 years, 3 months ago (2012-09-06 10:39:01 UTC) #6
hausner
http://codereview.chromium.org/10905109/diff/4001/tests/language/bad_constructor_test.dart File tests/language/bad_constructor_test.dart (right): http://codereview.chromium.org/10905109/diff/4001/tests/language/bad_constructor_test.dart#newcode4 tests/language/bad_constructor_test.dart:4: // VMOptions=--constructor_name_check Yes, this flag goes away as soon ...
8 years, 3 months ago (2012-09-06 16:18:37 UTC) #7
siva
I believe the case we discussed offline needs to be fixed also. http://codereview.chromium.org/10905109/diff/4001/runtime/vm/parser.cc File runtime/vm/parser.cc ...
8 years, 3 months ago (2012-09-06 16:52:10 UTC) #8
hausner
8 years, 3 months ago (2012-09-06 18:02:13 UTC) #9
Thanks for catching the error.

http://codereview.chromium.org/10905109/diff/4001/runtime/vm/parser.cc
File runtime/vm/parser.cc (right):

http://codereview.chromium.org/10905109/diff/4001/runtime/vm/parser.cc#newcod...
runtime/vm/parser.cc:2416: }
On 2012/09/06 16:52:10, asiva wrote:
> As discussed offline how do we report errors for the case of a field or
function
> appearing after the named constructor?
Correct. We really should have a simpler way to record the names in a scope. I
moved the check so it's now performed after the class is parsed.

http://codereview.chromium.org/10905109/diff/4001/tests/language/bad_construc...
File tests/language/bad_constructor_test.dart (right):

http://codereview.chromium.org/10905109/diff/4001/tests/language/bad_construc...
tests/language/bad_constructor_test.dart:27: A.foo() : m = 0;  /// 06:
compile-time error
On 2012/09/06 16:52:10, asiva wrote:
> 
> We should add a test where the named constructor and field are flipped, e.g:
> 
> A.error() : ...
> var error;  /// 07: compile-time error

Done.

Powered by Google App Engine
This is Rietveld 408576698