-
Notifications
You must be signed in to change notification settings - Fork 601
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hclsyntax: Special error messages for EOF in certain contexts
For parts of the input that are delimited by start and end tokens, our typical pattern is to keep scanning for items until we reach the end token, or to generate an error if we encounter a token that isn't valid. In some common examples of that we'll now treat TokenEOF as special and report a different message about the element being unclosed, because it seems common in practice for folks to leave off closing delimiters and then be confused about HCL reporting a parse error at the end of the file. Instead, we'll now report the error from the perspective of the opening token(s) and describe that construct as "unclosed", because the EOF range is generally less useful than any range that actually contains some relevant characters. This is not totally comprehensive for all cases, but covers some situations that I've seen folks ask about, and some others that were similar enough to those that it was easy to modify them in the same ways. This does actually change one of the error ranges constrained by the specification test suite, but in practice we're not actually using that test suite to represent the "specification" for HCL, so it's better to change the hypothetical specification to call for a better error reporting behavior than to retain the old behavior just because we happened to encoded in the (unfinished) test suite.
- Loading branch information
1 parent
e84201c
commit 81b680d
Showing
4 changed files
with
418 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.