Missing warning for invalid recursive val.
See original GitHub issueCompiler version
3.1.1
Minimized code
val a: Int = a
https://scastie.scala-lang.org/9Naw4C8JRuKQtPd0VXBXLw
No warnings or compilation errors
Expectation
Compiler error or warning.
Scala 2 gives value a in object Playground does nothing other than call itself recursively
Without warning, this is easy to create bugs like this. For eg:
def create[F[_], S](using enc: Encoder[S])(state: S, fsm: FSM[F, S, Cmd, Option[Stat]]) =
new Stat[F]:
val state = state
val fsm = fsm
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Missing recursion alert · Issue #11614 · scala/bug - GitHub
Self-recursive and self-explanatory: scala> val x: Int = x ^ warning: value x does nothing other than call itself recursively x: Int =...
Read more >return not exiting recursive method as expected - C# - Stack ...
I've got a recursive method creating a Collatz sequence (using as recursion practice) However once my method reaches the requirements for exit I ......
Read more >Recursion and stack - The Modern JavaScript Tutorial
Loop for(val of Object.values(obj)) to iterate over object values: Object.values returns an array of them. Recursive structures. A recursive ...
Read more >How to Fix the R Error: missing value where true/false needed
The fix for this error is quite simple. All you need to do embed your “if statement” or “while statement” in another “if...
Read more >ISPF messages starting with ISP - IBM
Previous "cccccccc" tag attribute was missing or not valid. ... Recursion error - Recursive use of an ISPF function ( aaaaaaaa ) is...
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
There is still something we want to improve, in particular, better error messages for handling inner classes, and improve the modularity of the check (warn for subtle initialization behavior of open class/traits).
And we also want to get more community feedback before turning it on by default.
Excellent, indeed:
Is it? Shouldn’t we encourage users interested in these checks to use
-Ysafe-init
instead, as it is a way more robust and powerful alternative to the shallow checks we could add by default?@Swoorup could you use this flag for your use-cases?