Skip to content

fix(compiler): incorrect spans for AST inside input value with leading space #63082

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

Closed
wants to merge 1 commit into from

Conversation

crisbeto
Copy link
Member

When parsing expressions inside a bound attribute, we offset all of its spans by an absoluteOffset in order to get the right spans in the source file. The offset was incorrect when parsing an attribute with leading spaces during the construction of the Ivy AST, because of the combination of:

  1. We were setting the offset by looking at valueSpan.start.
  2. The Ivy parser sets leadingTriviaChars: [' ', '\n'] which means that spaces and new lines will be ignored in the sourceSpan.start.

These changes resolve the issue by using valueSpan.fullStart which includes the leading spaces.

Fixes #63069.

…g space

When parsing expressions inside a bound attribute, we offset all of its spans by an `absoluteOffset` in order to get the right spans in the source file. The offset was incorrect when parsing an attribute with leading spaces during the construction of the Ivy AST, because of the combination of:
1. We were setting the offset by looking at `valueSpan.start`.
2. The Ivy parser sets `leadingTriviaChars: [' ', '\n']` which means that spaces and new lines will be ignored in the `sourceSpan.start`.

These changes resolve the issue by using `valueSpan.fullStart` which includes the leading spaces.

Fixes angular#63069.
@crisbeto crisbeto added action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release labels Aug 11, 2025
@angular-robot angular-robot bot added the area: compiler Issues related to `ngc`, Angular's template compiler label Aug 11, 2025
@ngbot ngbot bot added this to the Backlog milestone Aug 11, 2025
@crisbeto crisbeto requested a review from devversion August 11, 2025 08:44
@crisbeto crisbeto removed the request for review from devversion August 11, 2025 08:51
@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer action: merge The PR is ready for merge by the caretaker labels Aug 11, 2025
atscott pushed a commit that referenced this pull request Aug 11, 2025
…g space (#63082)

When parsing expressions inside a bound attribute, we offset all of its spans by an `absoluteOffset` in order to get the right spans in the source file. The offset was incorrect when parsing an attribute with leading spaces during the construction of the Ivy AST, because of the combination of:
1. We were setting the offset by looking at `valueSpan.start`.
2. The Ivy parser sets `leadingTriviaChars: [' ', '\n']` which means that spaces and new lines will be ignored in the `sourceSpan.start`.

These changes resolve the issue by using `valueSpan.fullStart` which includes the leading spaces.

Fixes #63069.

PR Close #63082
@atscott
Copy link
Contributor

atscott commented Aug 11, 2025

This PR was merged into the repository by commit d17555a.

The changes were merged into the following branches: main, 20.1.x, 20.2.x

@atscott atscott closed this in d17555a Aug 11, 2025
atscott pushed a commit that referenced this pull request Aug 11, 2025
…g space (#63082)

When parsing expressions inside a bound attribute, we offset all of its spans by an `absoluteOffset` in order to get the right spans in the source file. The offset was incorrect when parsing an attribute with leading spaces during the construction of the Ivy AST, because of the combination of:
1. We were setting the offset by looking at `valueSpan.start`.
2. The Ivy parser sets `leadingTriviaChars: [' ', '\n']` which means that spaces and new lines will be ignored in the `sourceSpan.start`.

These changes resolve the issue by using `valueSpan.fullStart` which includes the leading spaces.

Fixes #63069.

PR Close #63082
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: merge The PR is ready for merge by the caretaker area: compiler Issues related to `ngc`, Angular's template compiler target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Leading whitespace in input value causes incorrect source span
3 participants