question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Misleading error message when trying to mix normal parameters and context parameters in the same parameter list

See original GitHub issue

Compiler 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(i: Int, using j: Int) = i + j
-- [E040] Syntax Error: ------------------------------------------
1 |def f(i: Int, using j: Int) = i + j
  |                    ^
  |                    ':' expected, but identifier found

Expectation

The compiler should point to the keyword using and explain that mixing normal and context parameters is not allowed.

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
som-snyttcommented, Jul 8, 2022

I tried a generic message

-- [E040] Syntax Error: tests/neg/i15614.scala:2:20 --------------------------------------------------------------------
2 |def f(i: Int, using j: Int) = i + j   // error // error
  |                    ^
  |                    ':' expected, but identifier found.
  |                    The soft token `using` was taken as an identifier in this context.
  |---------------------------------------------------------------------------------------------------------------------
  | Explanation (enabled by `-explain`)
  |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  | The soft token `using` has special meaning only in certain contexts.
   ---------------------------------------------------------------------------------------------------------------------

I’ll propose REPL rewrites soon as an experiment; perhaps it will automatically rewrite under -rewrite and otherwise just emit that there was a rewrite and stash on top of the history, so up-arrow fetches it. As with “helpful” help messages, it’s a fine line between being a chatty friend and the friend people ignore.

1reaction
rochalacommented, Jul 8, 2022

In my opinion that’s a linter responsibility. Anyway this error has to change because as you stated, this is unhelpful to the end user.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix common formatting issues for custom parameters
This article goes over how to format your custom parameters, and troubleshoot issues with how your tag was added to your site. It...
Read more >
Database Engine events and errors - SQL Server
Consult this MSSQL error code list to find explanations for error messages for SQL Server database engine events.
Read more >
SML/NJ Error Messages
This document contains lists of error and warning messages produced by the SML/NJ Version 110 compiler, sorted alphabetically, with short explanations and ...
Read more >
SQLSTATE values and common error codes - Db2 - IBM
A SELECT containing a non-ATOMIC data change statement successfully returned some rows, but one or more warnings or errors occurred. 0168B, An operation...
Read more >
JUnit 5 Tutorial: Writing Parameterized Tests - Petri Kainulainen
That's why the provided arguments must use the same order as the method parameters of our test method. There are two things I...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found