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

Issue 8772070: Check constness of default args (Closed)

Created:
9 years ago by Siggi Cherem (dart-lang)
Modified:
9 years ago
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Patch Set 1 #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+21 lines, -3 lines) Patch
M frog/evaluator.dart View 1 chunk +2 lines, -2 lines 1 comment Download
M frog/member.dart View 1 chunk +3 lines, -0 lines 1 comment Download
M frog/minfrog View 2 chunks +4 lines, -1 line 0 comments Download
A tests/language/src/ConstOptionalArgsNegativeTest.dart View 1 chunk +12 lines, -0 lines 1 comment Download

Messages

Total messages: 3 (0 generated)
Siggi Cherem (dart-lang)
9 years ago (2011-12-03 02:23:00 UTC) #1
Jennifer Messerly
lgtm
9 years ago (2011-12-05 00:56:28 UTC) #2
jimhug
9 years ago (2011-12-06 16:23:39 UTC) #3
LGTM!

But I'd appreciate it if you could fix the error message in some future checkin.

http://codereview.chromium.org/8772070/diff/1/frog/evaluator.dart
File frog/evaluator.dart (right):

http://codereview.chromium.org/8772070/diff/1/frog/evaluator.dart#newcode63
frog/evaluator.dart:63: [List<Token> modifiers = const [], TypeReference type =
null]) {
This is really cool!  This particular code is a notorious source of bugs in
Python programs because no one can remember when the list is initialized.  As a
result, the rule in Python is - never use a list as a default argument value -
even though that is never enforced.  The fact that your change caught this issue
and also let us fix it by just adding const to the list says something excellent
about this feature in the dart language.

http://codereview.chromium.org/8772070/diff/1/frog/member.dart
File frog/member.dart (right):

http://codereview.chromium.org/8772070/diff/1/frog/member.dart#newcode64
frog/member.dart:64: world.error('default arguments must be constant',
value.span);
Pet peeve: 'default parameter values must be constant'

http://codereview.chromium.org/8772070/diff/1/tests/language/src/ConstOptiona...
File tests/language/src/ConstOptionalArgsNegativeTest.dart (right):

http://codereview.chromium.org/8772070/diff/1/tests/language/src/ConstOptiona...
tests/language/src/ConstOptionalArgsNegativeTest.dart:6: // should be 'const {}'
Thanks for including a test with your fix!

Powered by Google App Engine
This is Rietveld 408576698