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

Unified Diff: runtime/vm/parser.cc

Issue 12036088: Fix argument test for the captured parameter of an outer function (issue 8007). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 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 | tests/language/argument_definition4_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.cc
===================================================================
--- runtime/vm/parser.cc (revision 17587)
+++ runtime/vm/parser.cc (working copy)
@@ -7710,7 +7710,7 @@
return false;
}
if (ident.Equals(Symbols::This())) {
- // 'this' is not a formal parameter.
+ // 'this' is not a formal parameter that can be tested with '?this'.
return false;
}
// Since an argument definition test does not use the value of the formal
@@ -7718,16 +7718,19 @@
const bool kTestOnly = true; // No capturing.
LocalVariable* local =
current_block_->scope->LookupVariable(ident, kTestOnly);
- if (local == NULL) {
- if (!current_function().IsLocalFunction()) {
+ if ((local == NULL) ||
+ (local->owner()->HasContextLevel() &&
+ (local->owner()->context_level() < 1))) {
+ if ((local == NULL) && !current_function().IsLocalFunction()) {
// We are not generating code for a local function, so all locals,
// captured or not, are in scope. However, 'ident' was not found, so it
// does not exist.
return false;
}
- // The formal parameter may belong to an enclosing function and may not have
+ // The formal parameter belongs to an enclosing function and may not have
// been captured, so it was not included in the context scope and it cannot
// be found by LookupVariable.
+ ASSERT((local == NULL) || local->is_captured());
// 'ident' necessarily refers to the formal parameter of one of the
// enclosing functions, or a compile error would have prevented the
// outermost enclosing function to be executed and we would not be compiling
« no previous file with comments | « no previous file | tests/language/argument_definition4_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698