json: improve error message for duplicate property

We need to be careful to keep straight the distinction between JSON
properties and zcl body attributes here, since properties can represent
both attributes _and_ blocks.
This commit is contained in:
Martin Atkins 2017-05-20 11:12:03 -07:00
parent 45f97bf427
commit 873a4d07b5

View File

@ -154,12 +154,12 @@ Token:
// anyway since this is a semantic error we can recover from. // anyway since this is a semantic error we can recover from.
diags = diags.Append(&zcl.Diagnostic{ diags = diags.Append(&zcl.Diagnostic{
Severity: zcl.DiagError, Severity: zcl.DiagError,
Summary: "Duplicate object attribute", Summary: "Duplicate JSON object property",
Detail: fmt.Sprintf( Detail: fmt.Sprintf(
"An attribute named %q was previously introduced at %s", "An property named %q was previously introduced at %s",
key, existing.NameRange.String(), key, existing.NameRange.String(),
), ),
Subject: &colon.Range, Subject: &keyStrNode.SrcRange,
}) })
} }
attrs[key] = &objectAttr{ attrs[key] = &objectAttr{