Skip to content

Fix PrettyPrint corruption when user-definition header has a trailing…#3052

Open
anderson-joyle wants to merge 3 commits intomainfrom
A-TEAM/fix-prettyprint-comment-corruption
Open

Fix PrettyPrint corruption when user-definition header has a trailing…#3052
anderson-joyle wants to merge 3 commits intomainfrom
A-TEAM/fix-prettyprint-comment-corruption

Conversation

@anderson-joyle
Copy link
Copy Markdown
Contributor

… // comment

PrettyPrintVisitor.FormatUserDefinitions joined the trimmed declaration with the assignment operator using a single-space separator. When the original source placed a // line comment on the header line and the '=' body on the next line, Trim() stripped the newline that terminated the comment, and the subsequent " = " pushed the operator inside the // comment, corrupting the output so it could no longer be parsed back.

Detect when the trimmed declaration ends inside an unterminated // line comment (tracking /../ nesting so a // inside a block comment is ignored) and, in that case, insert a newline + 4-space indent before the operator. Applied uniformly to NamedFormula, UDF, and DefinedType branches.

Adds two xUnit InlineData cases in TestUserDefinitionsPrettyPrint: the exact repro from the issue and a mixed /../ + // UDF header that covers the generalization named in the issue title.

Issue: #2998

… // comment

PrettyPrintVisitor.FormatUserDefinitions joined the trimmed declaration with
the assignment operator using a single-space separator. When the original
source placed a // line comment on the header line and the '=' body on the
next line, Trim() stripped the newline that terminated the comment, and the
subsequent " = " pushed the operator inside the // comment, corrupting the
output so it could no longer be parsed back.

Detect when the trimmed declaration ends inside an unterminated // line
comment (tracking /*..*/ nesting so a // inside a block comment is ignored)
and, in that case, insert a newline + 4-space indent before the operator.
Applied uniformly to NamedFormula, UDF, and DefinedType branches.

Adds two xUnit InlineData cases in TestUserDefinitionsPrettyPrint:
the exact repro from the issue and a mixed /*..*/ + // UDF header that
covers the generalization named in the issue title.

Issue: #2998

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@anderson-joyle anderson-joyle requested a review from a team as a code owner April 21, 2026 01:37
@jas-valgotar
Copy link
Copy Markdown
Contributor

✅ No public API change.

@jas-valgotar
Copy link
Copy Markdown
Contributor

✅ No public API change.

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