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

Treat "non-exhaustive case" as warning #12

Closed
gnahtb opened this issue Sep 24, 2022 · 4 comments
Closed

Treat "non-exhaustive case" as warning #12

gnahtb opened this issue Sep 24, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@gnahtb
Copy link

gnahtb commented Sep 24, 2022

I'm referring to error 5011. I think we should treat "non-exhaustive case" as a warning instead of an error as the current implementation. Even in SMLNJ this is a warning.

Does the current language server support "warnings" or are there only "errors"?

image

image

@azdavis
Copy link
Owner

azdavis commented Sep 24, 2022

Millet reports every diagnostic as an error. But, since Millet doesn’t actually run any SML code, this shouldn’t stop you from ignoring the “error” and running your SML with e.g. SML/NJ.

Can you give some more detail about what it is you want to do here? If your intent is to ignore messages about non-exhaustiveness from Millet, you can already do that even when it’s reported as an error.

@gnahtb
Copy link
Author

gnahtb commented Sep 25, 2022

What I think is nice to have is to display different levels of "errors" on VSCode. For example, the warnings and informations have different "icons" in the "problems" list as below.

So instead of displaying with the red cross icon as above, the "non-exhaustive case" should be display using the yellow exclamation mark icon.

I also think that the TODO annotation feature is nice to have as well. Do we have that currently?

image

@azdavis
Copy link
Owner

azdavis commented Sep 25, 2022

Here's my opinion:

  • If we want to do this, it should be an option for whether to treat it like a warning or error. (It is an option in SML/NJ, defaulting to warn.)
  • The option should default to the current behavior (treat it like an error). Newer languages like Rust treat this as an error, which leads to less "warning noise" since it must be addressed to compile. (You can use the fill case feature to fill in all the unmatched branches, or just a wildcard: _.)
  • I'm not sure where the config for this option should be in the user settings (i.e. .vscode/settings.json) or project settings (millet.toml). Probably the latter.
  • This seems like a minor enough feature that I'm not going to prioritize implementing it right now. But feel free to send a patch.

As for the TODO thing, given that TODO is not a SML-specific thing, Millet wouldn't be the right place to implement anything to do with TODO comments. There are extensions which highlight TODO and other comments, like this one.

@azdavis azdavis added the enhancement New feature or request label Sep 25, 2022
@azdavis
Copy link
Owner

azdavis commented Oct 5, 2022

v0.3.13 adds the ability to override error severity in millet.toml on a by-error-code basis.

Add the following to your millet.toml to set non-exhaustive (case | binding) errors to display as warnings:

[errors]
5011.severity = "Warning"
5012.severity = "Warning"

Screen Shot 2022-10-05 at 12 56 01 AM

@azdavis azdavis closed this as completed Oct 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants