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

Unified Diff: tools/gn/function_forward_variables_from.cc

Issue 1943583002: GN: forward_variables_from shouldn't clobber vars. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
Index: tools/gn/function_forward_variables_from.cc
diff --git a/tools/gn/function_forward_variables_from.cc b/tools/gn/function_forward_variables_from.cc
index dd3629b8f2395e52c0f7677f45e5d9e5f91f0173..8f3b90dec716655748087a65a1ccb368275af065 100644
--- a/tools/gn/function_forward_variables_from.cc
+++ b/tools/gn/function_forward_variables_from.cc
@@ -54,6 +54,18 @@ void ForwardValuesFromList(Scope* source,
return;
}
+ // Don't allow clobbering existing values.
+ const Value* existing_value = dest->GetValue(storage_key);
+ if (existing_value) {
+ *err = Err(cur, "Clobbering existing value.",
+ "The current scope already defines a value \"" +
+ cur.string_value() + "\".\nforward_variables_from() won't clobber "
+ "existing values. If you want to\nmerge lists, you'll need to "
+ "do this explicitly.");
+ err->AppendSubErr(Err(*existing_value, "value being clobbered."));
+ return;
+ }
+
// Keep the origin information from the original value. The normal
// usage is for this to be used in a template, and if there's an error,
// the user expects to see the line where they set the variable

Powered by Google App Engine
This is Rietveld 408576698