Should I invest time to create a bug report

Hi, I’m new so please let me know if I behave improperly.

I just added some new lines of code in my project and the compiler crashed with the following message:

warning: an unexpected type representation reached the compiler backend while compiling MinervaIV.scala: . If possible, please file a bug on issues.scala-lang.org.
scala.MatchError: (of class scala.reflect.internal.Types$ErrorType$)

I enjoy Scala very much and my company only writes Scala-code. So I want to help where I can, but my time is limited. If I submit this, I have to spend time stripping my project code such that I am left with a small set of lines that generate the error.

Can anyone inform me if my time invested is worth it for the scala-developers, or should I upgrade to a newer version(currently using: 02.12.20)

Thanks in advance.

Definitely try 2.12.3 first to see if it’s already fixed.

If you can strip it down to a small example that’s great, but if you can also report it with a larger codebase together with clear instructions how to reproduce. Since you say you just added some new lines, say in the bug report which new code triggers the crash.

Thanks!

Ok. I will try 2.12.3 first.

As I continued to find a workaround, I discovered an error in my code. It is a single line that I understand would not result in compilable code, but I’d expect an error message instead of a crash of the compiler. This info might just help me in singleing out the error to a small snippet of code.

Thanks for your info.

Hi Irytz.

I checked and the compiler-error still exists in 2.12.3. I’ve even have a 20 line code example that produces a compiler-crash. But I found the way to report a bug far to complicated for me. I do not use Github at all and it looks to me like I should install stuff to report the bug. Thats something I dont want to do.

So I will leave the example code here for anyone to upload it in this Github tool. Ik hope this was of any help to the Scala Team.

Code:

package nl.datakneder.run
{
object Bug
{
def main(args : Array[String])
{
var lines : List[String] = List()
var lineNumber = 0

                    lines = 
                        lines
                            .map(
                                {c => 
                                    lineNumber += 1
                                })
                }
        }
}

This code will let the compiler (scala 2.12.3) crash as I’d expect it to say:

error: type mismatch;
found : List[Unit]
required: List[String]
.map(
^
one error found

Here’s a smaller part of the problem. Assignment to a mutable variable is being typed as Nothing instead of the expected Unit inside a lambda:

scala> var n = 0
n: Int = 0

scala> List(1).map(_ => n += 1): Int
<console>:13: error: type mismatch;
 found   : List[Nothing]
 required: Int
       List(1).map(_ => n += 1): Int
                  ^

yawaramin’s example is much more concise and therefor more elegant. My problem however is not in the fact that the assignment is of the type Nothing instead of Unit. Although I might have mislead the readers by saying i’d expect List[Unit]. For me List[Nothing] would also be good.

But to explain the problem better and being inspired by yawaramin here’ s my example in command lines:


scala> var lines : List[String] = List()
lines: List[String] = List()

scala> var lineNumber = 0
lineNumber: Int = 0

scala> lines = lines.map({_ => lineNumber += 1})

[A whole lot of lines with error messages]

That entry seems to have slain the compiler. Shall I replay
your session? I can re-run each line except the last one.
[y/n]


My problem lies in the fact that de compilter crashes, rather than the type being something else to what I was expecting. I hope this clears up things a bit.

Nothing needs to be installed to report a bug. All you need is a GitHub account.

To the original question, I’d suggest doing what you need to do to accomplish your task.

Usually that means asking on the forum or SO, searching the issues on github, and trying to work around the behavior (iteratively tweaking code or else avoiding a feature entirely). If that gets you close to a minimization, then it’s worth opening an issue.

But it’s not necessarily a good investment of your time to research the bug to create a good ticket, if the expected payoff is an improved ecosystem.

In your minimization, it looks like the error in the lambda expression isn’t propagated.

It also fails with https://github.com/scala/scala/pull/6007.

@som-snytt: I think I just did what you proposed.

For the work I was doing when the bug first appeared to me, it was obvious that I had to find a workaround and that’s what I did.

Nonetheless I would also prefer a better Scala compiler, so I tried to find a small example that produced the bug. That lead to my first entry of 20 lines. The only thing was that this Github-thing was not my cup of tea, making the search if the issue was already entered too time consuming for me. With the help from @yawaramin I was able to reduce the problem to three lines.

Your input tells me that this bug was already ticketed so I’m satisfied that the developers are aware of this ‘problem’. Thank you for pointing this out.

I think it’s a new issue, so thanks for bringing it up. (Edit: I updated the issue.)

Github is pretty amazing, though I remember setting up for contributing is not trivial.

I kind of dreaded signing up for this forum. In compensation, I’m unsubscribed from google groups and don’t worry as much about missing conversations on gitter.

@som-snytt Thank you for editing the info into the Github issue. At this point I’m just too busy and can’t find the time to dive into Github. Especially signing up is not trivial. But as soon as I have the time I’ll have a look.

I’m not afraid missing out, so there are no forums I regulary check. Although I use forums to help me getting some idea of some problems I encounter. So I’m grateful being able to contribute a tiny bit to the improvement of Scala.