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

AttributeRemover outputs a leading newline in some cases #2269

Open
gohanlon opened this issue Oct 7, 2023 · 1 comment
Open

AttributeRemover outputs a leading newline in some cases #2269

gohanlon opened this issue Oct 7, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@gohanlon
Copy link
Contributor

gohanlon commented Oct 7, 2023

Description

#2247 better isolates the AttributeRemoverTests to just AttributeRemover. Along the way, a new assert helper was created that, unlike assertMacroExpansion, doesn't trim newlines before comparing values.

Notably, this revealed a previously undetected behavior in AttributeRemover: it outputs an additional leading newline when the removed attribute isn't preceded by any tokens. For instance:

assertSyntaxRemovingTestAttributes {
  """
  @Test
  var x: Int
  """
} reduction: {
  "var x: Int"
}
//failed - Attribute removal did not produce the expected reduced source
//+
// var x: Int
//
//Actual reduced source:
//
//var x: Int

and:

assertSyntaxRemovingTestAttributes {
  """
  @Test
  /* comment */
  var value: Int
  """
} reduction: {
  """
  /* comment */
  var value: Int
  """
}
//failed - Attribute removal did not produce the expected reduced source
//+
// /* comment */
// var value: Int
//
//Actual reduced source:
//
///* comment */
//var value: Int

The following tests outputs have an extra leading newline:

Before #2247, this behavior is masked by assertMacroExpansion. In #2247, the above tests are "fixed" by including the unwanted leading newlines in the expected output and marking those tests with FIXMEs (to be properly fixed in a separate PR).

Steps to Reproduce

No response

@gohanlon gohanlon added the bug Something isn't working label Oct 7, 2023
@ahoppen
Copy link
Member

ahoppen commented Oct 7, 2023

Tracked in Apple’s issue tracker as rdar://116607739

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants