Skip to content

Conversation

hlindberg
Copy link
Contributor

Before this, heredoc set up a locator intended to define a subspace
for the heredoc string (for lexing its content to support
interpolation). What it ended up doing was to create a subspace offset
not from the total source string, but from within the heredoc string.
This resulted in offsets being calculated to point to char positions in
an undefined manner (depending of length of heredoc, its position and
what follows). This would then result in error messages pointing to the
wrong place in the source code as well as wrongly computing if a [ is
an array start or not by checking if the preceding char is a space since
it would end up looking at some undefined position.

This was made worse (or the same) because the lexer would use the
returned char_offset as an offset in its subspace string instead of in
the total space.

sublexer = self.class.new()
locator = Locator::SubLocator.sub_locator(str,
locator.file, heredoc_line, heredoc_offset, leading.length())
locator = Locator::SubLocator.new(locator, heredoc_line, heredoc_offset, leading.length())
Copy link
Contributor

Choose a reason for hiding this comment

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

Misaligned indentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

meh - fixed - new version force pushed

Before this, heredoc set up a locator intended to define a subspace
for the heredoc string (for lexing its content to support
interpolation). What it ended up doing was to create a subspace offset
not from the total source string, but from within the heredoc string.
This resulted in offsets being calculated to point to char positions in
an undefined manner (depending of length of heredoc, its position and
what follows). This would then result in error messages pointing to the
wrong place in the source code as well as wrongly computing if a `[` is
an array start or not by checking if the preceding char is a space since
it would end up looking at some undefined position.

This was made worse (or the same) because the lexer would use the
returned char_offset as an offset in its subspace string instead of in
the total space.
@hlindberg hlindberg force-pushed the PUP-9163_locator-for-heredoc-subspace-is-wrong branch from fe0ad58 to 49b42a5 Compare September 24, 2018 18:49
@jhelwig jhelwig merged commit 452dded into puppetlabs:5.5.x Sep 24, 2018
@puppetcla
Copy link

CLA signed by all contributors.

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.

3 participants