Skip to content

Compiler warnings do not appear in the output #123

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

Closed
nrinaudo opened this issue Dec 31, 2018 · 5 comments
Closed

Compiler warnings do not appear in the output #123

nrinaudo opened this issue Dec 31, 2018 · 5 comments

Comments

@nrinaudo
Copy link

Given the following code:

```scala mdoc
def unwrap(oi: Option[Int]): Int = oi match {
  case Some(i) => i
}

I would expect the mdoc output to contain the non-exhaustivity warning, or to have a :warnings modifier of some sort to do so.

What I get instead is:

def unwrap(oi: Option[Int]): Int = oi match {
  case Some(i) => i
}

Note that there's an easy workaround, which is to make compiler warnings fatal and use :fail, but this might have other unwanted side effects.

@olafurpg
Copy link
Member

Thanks for reporting! I'm able to reproduce the timeout, not sure what's going on here 🤔

@nrinaudo
Copy link
Author

I believe this comment is on the wrong issue :)

@olafurpg
Copy link
Member

olafurpg commented Jan 1, 2019

Whoops, that comment was supposed to be for #124. Still, I'm able to reproduce.

It's not necessary to enable fatal warnings to print the warning, :fail also works when there are only warnings and produces the following output:

def unwrap(oi: Option[Int]): Int = oi match {
  case Some(i) => i
}
// warning: match may not be exhaustive.
// It would fail on the following input: None
// def unwrap(oi: Option[Int]): Int = oi match {
//                                    ^^

Is that an acceptable workaround? We could add a :warning modifier which fails only if there's a warning (not error), but I'd prefer to not introduce unnecessary modifiers when :fail already works.

With :fail it's not possible to evaluate the program however, is that necessary for your use case? I think it might be possible to support it but it's not straightforward how to implement it.

@nrinaudo
Copy link
Author

nrinaudo commented Jan 1, 2019

In a way mdoc basically already considers warnings to be fatal, then?

I'm trying to think of scenarios where this wouldn't be acceptable. Maybe in documentation that demonstrates a bit of code that generates a warning, then uses that code to show the warning was correct?

I think in my case it's perfectly sufficient, but there will inevitably be someone down the line that'll need to have warnings output and still evaluate the program :)

@olafurpg
Copy link
Member

olafurpg commented Jan 1, 2019

Sounds good, let's close this issue then and let somebody else start a new discussion if they want to display warnings AND evaluate the code.

@olafurpg olafurpg closed this as completed Jan 1, 2019
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

No branches or pull requests

2 participants