Skip to content

Add # typeprof:disable/enable directive for silencing diagnostics #306

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

smasato
Copy link
Contributor

@smasato smasato commented Apr 19, 2025

Overview

This PR adds RuboCop‑style comment directives that let users silence TypeProf diagnostics.

foo(1, 2) # typeprof:disable           # inline – only this line

# typeprof:disable                     # block start
foo(1, 2)
bar(1, 2)
# typeprof:enable                      # block end

The feature works in CLI and **LSP modes
CleanShot 2025-04-19 at 21 30 44
CleanShot 2025-04-19 at 21 29 16


Implementation notes

  • Diagnostic::DisableDirective::Scanner – parses comments and returns muted line ranges.
  • Diagnostic::DisableDirective::Filter – determines whether a diagnostic should be reported.
  • ProgramNode#diagnostics applies the filter. I implemented the filtering logic in ProgramNode, but please let me know if there is a better way.

Related issue

Closes #108

@mame
Copy link
Member

mame commented Apr 22, 2025

Awesome job, thanks!

Let me think this for a while before merging. I'm a little concerned about whether typeprof:enable is good or not. Also, the amount of changes is relatively large that I want to do a design-level review. This will take some time.

@smasato
Copy link
Contributor Author

smasato commented Apr 22, 2025

@mame
Thanks for the comment!

I followed RuboCop’s style, so # typeprof:disable/enable only turns diagnostics on or off for that block—it never touches the type‑inference logic itself. That wording might still confuse users, so I’m open to better keywords. Let me know what you think whenever you’re ready.

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.

A feature to ignore errors on a specified line
2 participants