Skip to content

WIP #4721 try improving errors #4970

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
wants to merge 4 commits into from

Conversation

Blaisorblade
Copy link
Contributor

@Blaisorblade Blaisorblade commented Aug 20, 2018

When a type argument violates its bounds, we give the same errors whether the argument is specified by the user or inferred by the compiler. This PR is an (incomplete) attempt to detect and fix that. However, I failed to distinguish reliably inferred and synthesized type arguments, even following #4946 (comment)

This PR builds on #4946 to try improving the resulting error output. Sadly, the position of inferred arguments fails both isSynthetic and isZeroExtent (arg.pos [53..54], false).

sbt:dotty> dotc -d out tests/neg/i4721a.scala
[info] Compiling 1 Scala source to /Users/pgiarrusso/git/dotty/compiler/target/scala-2.12/classes ...
[info] Done compiling.
[warn] Multiple main classes detected.  Run 'show discoveredMainClasses' to see the list
[info] Packaging /Users/pgiarrusso/git/dotty/compiler/target/scala-2.12/dotty-compiler_2.12-0.10.0-bin-SNAPSHOT-nonbootstrapped.jar ...
[info] Done packaging.
[info] Running (fork) dotty.tools.dotc.Main -classpath /Users/pgiarrusso/git/dotty/library/../out/bootstrap/dotty-library-bootstrapped/scala-0.10/dotty-library_0.10-0.10.0-bin-SNAPSHOT.jar -d out tests/neg/i4721a.scala
-- Warning: tests/neg/i4721a.scala:2:39 ----------------------------------------
2 |  def main(args: Array[String]):Unit = m("1") // error
  |                                       ^
  |       Unsatisfiable type parameter constraints in polymorphic application
arg.pos [53..54], false
-- [E057] Type Mismatch Error: tests/neg/i4721a.scala:2:39 ---------------------
2 |  def main(args: Array[String]):Unit = m("1") // error
  |                                       ^
  |                 Type argument Int does not conform to upper bound String
one warning found
one error found

We will get some other error when checking bounds in PostTyper,
unless we get a failure in Typer which might produce questionable errors. Having
a warning here might be better than nothing.

```scala
-- Warning: tests/neg/i4721.scala:2:39 -----------------------------------------
2 |  def main(args: Array[String]):Unit = m(1) // error
  |                                       ^
  |       Unsatisfiable type parameter constraints in polymorphic application
-- [E007] Type Mismatch Error: tests/neg/i4721.scala:2:41 ----------------------
2 |  def main(args: Array[String]):Unit = m(1) // error
  |                                         ^
  |                                         found:    Int(1)
  |                                         required: String
  |
one warning found
one error found
```
@Blaisorblade Blaisorblade self-assigned this Aug 24, 2018
@odersky
Copy link
Contributor

odersky commented Jan 12, 2019

@Blaisorblade Inactive for almost 5 months. Can you either finish the PR or close it and re-assign the issue to someone else? Thanks

@Blaisorblade
Copy link
Contributor Author

After discussion, assigned to @AleksanderBG as he's working in the area.

@b-studios
Copy link
Contributor

@abgruszecki what is the status on this PR? Should we close it?

@abgruszecki
Copy link
Contributor

I think it can be safely closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants