Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Undocumented(?) always available given: T => T #36

Open
Sporarum opened this issue Oct 6, 2021 · 0 comments
Open

Undocumented(?) always available given: T => T #36

Sporarum opened this issue Oct 6, 2021 · 0 comments
Labels
intent:add-knowledge You have learnt something while working on the Dotty compiler and you want to preserve this info

Comments

@Sporarum
Copy link

Sporarum commented Oct 6, 2021

Hello,
I have discovered that the type T => T (for all T) is given, the following example compiles and run (scalaVersion := 3.0.2):

type A
def auto[T](using tt: T => T) = tt
@main def autoGiven = auto[A]

(doesn't compile if T => T is replaced by T)

This was unexpected, and I did not find any mention of it in the docs, for example there's no mention of it here:
https://docs.scala-lang.org/scala3/reference/contextual/givens.html

(I know as a rule you should wrap types in something to avoid unexpected givens like that, but for prototyping purposes I wasn't doing it)

The problem is not necessarily this unexpected behavior, rather that even having read documentation, it was still unexpected

Thank you for your time, hope this helps

@Sporarum Sporarum added the intent:add-knowledge You have learnt something while working on the Dotty compiler and you want to preserve this info label Oct 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
intent:add-knowledge You have learnt something while working on the Dotty compiler and you want to preserve this info
Projects
None yet
Development

No branches or pull requests

1 participant