scala3 icon indicating copy to clipboard operation
scala3 copied to clipboard

Error about a missing `using` clause incorrectly suggests use of -rewrite to fix.

Open reid-spencer opened this issue 11 months ago • 3 comments

Compiler version

3.4.0

Minimized example

A code example is not highly relevant to this issue, but you can find one here:

  • https://github.com/reid-spencer/scala-3.4-19872 This has to do with using fastparse 3.0.2 with scalac 3.4.0. The message produced only occurs in 3.4.0 and does not occur in 3.3.1 or 3.3.3

Output Error/Warning message

[error] 60 |    parseRule[Root](input, root(_), withVerboseFailures) {
[error]    |                           ^^^^
[error]    |                           Context bounds will map to context parameters.
[error]    |                           A `using` clause is needed to pass explicit arguments to them.
[error]    |                           This code can be rewritten automatically under -rewrite -source 3.4-migration.
>print scalacOptions
* -deprecation
* -feature
* -new-syntax
* -explain-types
* -Werror
* -pagewidth:120
* -rewrite
* -source
* 3.4-migration
* -explain

Why this Error/Warning was not helpful

The direction to use the -rewrite -source 3.4-migration option isn't applicable or helpful. As you can see, both these options were provided to the compiler. It rewrote nothing. Furthermore, it is not clear where this using clause should be placed.

Suggested improvements

A few ideas:

  • Drop the last line of the message since no attempt to rewrite the code is ever made.
  • If rewriting is an option, place the rewritten code in the error message
  • If rewriting is not an option, provide instructions on where/how to make the needed modifications

reid-spencer avatar Mar 04 '24 16:03 reid-spencer