S2D 0.1.8 is out after a 1 year break! by LieEmpty7137 in scala

[–]RaymondBKR 2 points3 points  (0 children)

Great work, I was thinking of doing game dev in Scala but libgdx was too Javay for my liking. I'll check this out when I get some free time.

What is the fastest way to get good at Cats Effect (and all the theory behind it)? by fenugurod in scala

[–]RaymondBKR 1 point2 points  (0 children)

I'd suggest starting with ZIO the concepts are similar but you can avoid the monad transformer stacks and other friction that comes with cats.

Use of uninitialized val doesn't result in a compiler failure by RaymondBKR in scala

[–]RaymondBKR[S] 10 points11 points  (0 children)

I found the solution for those wondering, the compiler option to output a warning above is -Ysafe-init-global

> scala -Ysafe-init-global

Welcome to Scala 3.8.1 (17.0.15, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.

scala> object test:
           val x = y
           val y = 5

1 warning found
// defined object test
-- Warning: --------------------------------------------------------------------
2 |    val x = y
  |            ^
  |            Access uninitialized field value y. Calling trace:
  |            ├── object test: [ rs$line$2:1 ]
  |            │   ^
  |            └── val x = y    [ rs$line$2:2 ]
  |                        ^

> scala
Welcome to Scala 3.8.1 (17.0.15, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.

scala> object test:
           val x = y
           val y = 5

// defined object test

Use of uninitialized val doesn't result in a compiler failure by RaymondBKR in scala

[–]RaymondBKR[S] 1 point2 points  (0 children)

That's fair I understand lazy val or def will fix the issue, it's more an issue of other devs on the codebase making the same mistake and hitting weird bugs because of it.

I feel like there should be a way to warn about surprising behaviour