Skip to content

[bug] relaxed strictness does not ignore all comments in the source #2122

@evangalen

Description

@evangalen

Please read the FAQ for the bug you encountered.

  • I have read the existing FAQ

⏯ Playground Link

https://ast-grep.github.io/playground.html#eyJtb2RlIjoiUGF0Y2giLCJsYW5nIjoidHlwZXNjcmlwdCIsInF1ZXJ5IjoiJEEoJEIpIiwicmV3cml0ZSI6IiIsInN0cmljdG5lc3MiOiJyZWxheGVkIiwic2VsZWN0b3IiOiIiLCJjb25maWciOiIiLCJzb3VyY2UiOiIvLyBtYXRjaGVzXG5mb28oYmFyIC8qIC4uICovKVxuZm9vKFxuICBiYXIgLy8gLi5cbilcbmZvbyhcbiAgYmFyLCAvLyAuLlxuKVxuXG4vLyBubyBtYXRjaGVzXG5mb28oLyogLi4gKi8gYmFyKVxuZm9vKCAvLyAuLlxuICBiYXJcbilcbiJ9

💻 Code

Using the pattern $A($B) with relaxed doesn't seem to correctly ignore all comments in the source code.

// matches
foo(bar /* .. */)
foo(
  bar // ..
)
foo(
  bar, // ..
)

// no matches
foo(/* .. */ bar)
foo( // ..
  bar
)

🙁 Actual behavior

Only comments after the last argument of the call expression seem to be ignored.

🙂 Expected behavior

Comments placed before the last argument should also be ignored with using relaxed strictness.

Additional information about the issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions