Misleading error message when forgetting `using` in explicitly given context argument
See original GitHub issueCompiler version
Welcome to Scala 3.1.3 (17.0.3, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
Minimized code and output
scala> def f(using i: Int) = i + 1
def f(using i: Int): Int
scala> f(41)
-- Error: -----------------------------------------------
1 |f(41)
| ^
| no given instance of type Int was found for parameter i of method f
1 error found
Expectation
It is true that there is no given instance above, but the call is still erroneous and the error message does not help if the user just forgot an explicit using
before the explicit argument. Even if a given is missing, something similar to this error should (also) be shown :
scala> f(41)
-- [E050] Type Error: ---------------------------------------
|^
|method f does not take more parameters
|
| longer explanation available when compiling with `-explain`
1 error found
but it would be more helpful if a hint that “you may have forgotten using
” also is given.
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Master List of Logical Fallacies
Master List of Logical Fallacies. Fallacies are fake or deceptive arguments, "junk cognition," that is, arguments that seem irrefutable but prove nothing. ...
Read more >Context Managers and Python's with Statement
Note: A common mistake when you're using context managers is forgetting to call the object passed to the with statement. The exception message...
Read more >A Definitive Guide to Handling Errors in JavaScript - Kinsta
It usually occurs when passing a value as an argument to a function, and the given value doesn't lie in the range of...
Read more >R: '...' used in an incorrect context - Stack Overflow
I have looked at about 40 instances of this error on stackoverflow, ... other instances displayed, and I do not know what is...
Read more >Explanation of the error messages for the W3C Markup Validator
forgetting to quote an attribute value (where characters such as "%" and "/" are common, but cannot appear without surrounding quotes), or; using...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ll take a quick look; it’s probably an easy tweak; I just added benign
using
to Scala 2 and was contemplating misusages. Lukas said what aboutf(using using)
.I do think that if the user has forgotten
using
but meant to call it with an explicit argument then the current error message could be more helpful. If it is possible to make the hint in only those cases were it is a valid rewrite to addusing
then I think it is worthwhile to give the hint that it may be missing.