Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hclwrite: Fix panic for dotted full splat (foo.*) #374

Merged
merged 1 commit into from
May 14, 2020

Conversation

alisdair
Copy link
Contributor

The following expression caused a panic in hclwrite:

a = foo.*

This was due to the unusual dotted form of a full splat (where the splat operator is at the end of the expression) being generated with an invalid source range. In the full splat case, the end of the range was uninitialized, which caused the token slice to be empty, and thus the panic.

This commit fixes the bug, adds test coverage, and includes some bonus tests for other splat expression cases.

Bug reported in apparentlymart/terraform-clean-syntax#7

The following expression caused a panic in hclwrite:

  a = foo.*

This was due to the unusual dotted form of a full splat (where the splat
operator is at the end of the expression) being generated with an
invalid source range. In the full splat case, the end of the range was
uninitialized, which caused the token slice to be empty, and thus the
panic.

This commit fixes the bug, adds test coverage, and includes some bonus
tests for other splat expression cases.
@alisdair alisdair requested a review from a team May 13, 2020 20:26
Copy link
Contributor

@apparentlymart apparentlymart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants