aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbuild2/parser.cxx13
-rw-r--r--tests/type/json/testscript3
2 files changed, 15 insertions, 1 deletions
diff --git a/libbuild2/parser.cxx b/libbuild2/parser.cxx
index 5572104..2623bf3 100644
--- a/libbuild2/parser.cxx
+++ b/libbuild2/parser.cxx
@@ -6257,7 +6257,7 @@ namespace build2
type kind)
{
attributes as (attributes_pop ());
- const location& l (as.loc);
+ const location& l (as.loc); // This points to value if no attributes.
// Essentially this is an attribute-augmented assign/append/prepend.
//
@@ -6376,6 +6376,17 @@ namespace build2
}
else
{
+ auto df = make_diag_frame (
+ [this, var, &l](const diag_record& dr)
+ {
+ if (!l.empty ())
+ {
+ dr << info (l);
+ if (var != nullptr) dr << "variable " << var->name << ' ';
+ dr << "value is assigned here";
+ }
+ });
+
if (kind == type::assign)
{
if (rhs)
diff --git a/tests/type/json/testscript b/tests/type/json/testscript
index 6dd6316..6beaf5d 100644
--- a/tests/type/json/testscript
+++ b/tests/type/json/testscript
@@ -91,6 +91,7 @@
o = [json] '{"one":1, "two":}'
EOI
error: invalid json value in variable o: invalid json input: unexpected byte '}' in value
+ <stdin>:1:5: info: variable o value is assigned here
EOE
: diagnostics-duplicate-member
@@ -99,6 +100,7 @@
o = [json] one@1 one@2
EOI
error: invalid json value in variable o: duplicate json object member 'one'
+ <stdin>:1:5: info: variable o value is assigned here
EOE
}
@@ -277,6 +279,7 @@
print $s
EOI
error: invalid json value in variable s: unable to append array to string
+ <stdin>:3:6: info: variable s value is assigned here
EOE
}