Chromium Code Reviews| Index: tools/gn/parse_tree.cc |
| diff --git a/tools/gn/parse_tree.cc b/tools/gn/parse_tree.cc |
| index ecc438b245aee02c62551efaee117796786dc02f..17f9396290a85b28eb87e6d821380d55d2ccc0ac 100644 |
| --- a/tools/gn/parse_tree.cc |
| +++ b/tools/gn/parse_tree.cc |
| @@ -487,13 +487,31 @@ const IdentifierNode* IdentifierNode::AsIdentifier() const { |
| } |
| Value IdentifierNode::Execute(Scope* scope, Err* err) const { |
| - const Value* value = scope->GetValue(value_.value(), true); |
| + const Scope *found_in_scope = nullptr; |
|
brettw
2016/11/18 22:07:43
Put the * next to the type like you do for Value b
Dirk Pranke
2016/11/18 22:35:40
ack.
|
| + const Value* value = scope->GetValueWithScope(value_.value(), true, |
| + &found_in_scope); |
| Value result; |
| if (!value) { |
| *err = MakeErrorDescribing("Undefined identifier"); |
| return result; |
| } |
| + // Check that the scope that contains the defined value and the |
|
brettw
2016/11/18 22:07:43
I think it would be easier to follow if this was i
Dirk Pranke
2016/11/18 22:35:39
Acknowledged.
|
| + // current scope are not part of the same declare_args() block, in |
| + // order to prevent reading a value that might be overridden later. |
| + const Scope *found_args_scope = nullptr; |
| + if (found_in_scope) |
| + found_in_scope->GetProperty(&kInDeclareArgsKey, &found_args_scope); |
| + |
| + const Scope* cur_args_scope = nullptr; |
| + scope->GetProperty(&kInDeclareArgsKey, &cur_args_scope); |
| + if (found_args_scope && cur_args_scope && |
| + (found_args_scope == cur_args_scope)) { |
| + *err = MakeErrorDescribing( |
| + "Reading a variable defined in the same declare_args() call."); |
| + return result; |
| + } |
| + |
| result = *value; |
| result.set_origin(this); |
| return result; |