You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There seems to be some solutions to type inference exercises that are incorrect in the current version of the compendium, presumably due to more precise type inference in newer Scala compiler versions for union types.
I recall finding a few of these errors in the past, but this is the only one I have noted down (Exercise 2C, W08):
The solution says:
However, when trying this myself using Scala REPL the compiler infer more precise types than Any and AnyVal:
I personally think that solutions to exercises like these have to be revised in order to not confuse students. Maybe we can include both the general and the precise type?
The text was updated successfully, but these errors were encountered:
Yes, with union types in Scala 3 the type inference is more precise now and all the types shown in repl sessions in answers to exercises should be inspected to see if they have changed from Scala 2 to Scala 3.
Thanks for PR @axelnilsson98
I guess there are more places where there could be more precise type in in Appendix Lösningar? so I'll keep this issue open until a search for Any and Matchable has been conducted and re-run in repl to see what we get in Scala >=3.5.0
There seems to be some solutions to type inference exercises that are incorrect in the current version of the compendium, presumably due to more precise type inference in newer Scala compiler versions for union types.
I recall finding a few of these errors in the past, but this is the only one I have noted down (Exercise 2C, W08):
The solution says:
However, when trying this myself using Scala REPL the compiler infer more precise types than Any and AnyVal:
I personally think that solutions to exercises like these have to be revised in order to not confuse students. Maybe we can include both the general and the precise type?
The text was updated successfully, but these errors were encountered: