% git diff
diff --git a/base/BUILD.gn b/base/BUILD.gn
index f764c0a..aace847 100644
--- a/base/BUILD.gn
+++ b/base/BUILD.gn
@@ -36,6 +36,12 @@ declare_args() {
override_build_date = "N/A"
}
+foo = false
+bar = true
+if (foo && bar) {
+ print("foo and bar")
+}
+
if (is_android) {
import("//build/config/android/rules.gni")
}
src $ gn gen out/Release
ERROR at //base/BUILD.gn:40:7: Assignment had no effect.
bar = true
^---
You set the variable "bar" here and it was unused before it went
out of scope.
See //BUILD.gn:190:5: which caused the file to be included.
"//base:base_unittests",
^----------------------
In this case, strictly speaking, the message is correct because foo can never be true and hence bar never needs to be read. However, if you change foo to be a declare_arg(), but don't set it, you get the same error, which is somewhere between confusing and wrong.
Interestingly, if you make the same change to //BUILD.gn you don't get the same error. I don't know why not.
Comment 1 by tsniatow...@opera.com
, Oct 2 2016