| Index: tools/gn/functions.cc
|
| diff --git a/tools/gn/functions.cc b/tools/gn/functions.cc
|
| index ac1c29492d15be5817f560f9ba02066c1dc99f0e..c8ae4690c2043f6332985503e996297c4b145611 100644
|
| --- a/tools/gn/functions.cc
|
| +++ b/tools/gn/functions.cc
|
| @@ -354,16 +354,26 @@ Value RunDefined(Scope* scope,
|
| if (accessor) {
|
| // Passed an accessor "defined(foo.bar)".
|
| if (accessor->member()) {
|
| - // The base of the accessor must be a scope if it's defined.
|
| + // The base of the accessor must be a scope/dict if it's defined.
|
| const Value* base = scope->GetValue(accessor->base().value());
|
| if (!base)
|
| return Value(function, false);
|
| - if (!base->VerifyTypeIs(Value::SCOPE, err))
|
| + if (base->type() == Value::SCOPE) {
|
| + // Check the member inside the scope to see if its defined.
|
| + if (base->scope_value()->GetValue(accessor->member()->value().value()))
|
| + return Value(function, true);
|
| + } else if (base->type() == Value::DICT) {
|
| + // Check the dictionary to see if the member is present.
|
| + if (base->dict_value().find(
|
| + accessor->member()->value().value().as_string()) !=
|
| + base->dict_value().end())
|
| + return Value(function, true);
|
| + } else {
|
| + *err = Err(function,
|
| + std::string("Type \"") + Value::DescribeType(base->type()) +
|
| + "\" is not usable with the '.' operator.");
|
| return Value();
|
| -
|
| - // Check the member inside the scope to see if its defined.
|
| - if (base->scope_value()->GetValue(accessor->member()->value().value()))
|
| - return Value(function, true);
|
| + }
|
| return Value(function, false);
|
| }
|
| }
|
|
|