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

Add in 061_TopLevelCantBeImplicit #9

Merged
merged 2 commits into from
Apr 14, 2022

Conversation

tanishiking
Copy link
Contributor

@tanishiking tanishiking commented Apr 14, 2022

Adding // LEGACY to 061.
It seems like TopLevelCantBeImplicit is no longer the case thanks to scala/scala3#5754

This is actually confirmed in https://github.com/lampepfl/dotty/blob/93fc41fcb624df73cc12d52b79d518a30a778a7c/tests/run/toplevel-implicits/a.b.scala#L19-L21


I'm planning to refactor the dotty repo to delete the TopLevelCantBeImplicit error message-id, and the check logic (as it's a dead code now). In that case, should we keep TopLevelCantBeImplicit in dotty-error-index repo?


Thank you very much for kicking off https://contributors.scala-lang.org/t/revisiting-dotty-diagnostics-for-tooling/5649/15 @ckipp01 ! This is definitely a good way to improve the devtools experience, the user experience of Scala (especially for newcomers).

@ckipp01
Copy link
Owner

ckipp01 commented Apr 14, 2022

Thanks so much for the contribution @tanishiking! You're the first one to contribute, so if you have any feedback about the CONTRIBUTING.md please do let me know! I now realize that my logic for auto-updating the index won't work for other prs since it can't commit back to your branch, I'll fix that.

Adding // LEGACY to 061.

This is sort of what I expected, thanks for confirming!

I'm planning to refactor the dotty repo to delete the TopLevelCantBeImplicit error message-id, and the check logic (as it's a dead code now). In that case, should we keep TopLevelCantBeImplicit in dotty-error-index repo?

So the id should actually never be removed in Dotty (it actually can't since it will screw up all the numbering). Just for documentation purposes we should keep the IDs, but the Message that uses that ID can be removed. I've been thinking a bit about this lately and I think we might need to change the ErrorMessageID enum to somehow be able to have an active field or something that we can mark an ID as legacy. I plan on digging into that as I get the sbt/zinc/problem stuff done. Any regarding keeping it in here, yea, I've been mimicking what they do in the rust one and they also keep legacy ones in there. I think it's a good idea just for documentation, plus if someone is using an older version of the compiler and they see an id that no longer exists, they'll still be able to look it up.

Copy link
Owner

@ckipp01 ckipp01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the CONTRIBUTING.md can you remove this ID from the Here is a list of ErrormessageIDs that aren't yet reproduced. section?

Comment on lines 5 to 8
import scala.language.implicitConversions
case class C(str: String)
implicit def toC(x: String): C = C(x)
implicit val defaultC: C = C("default")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might be even able to just put the most simple example possible to prove this. I'm assuming that just a top level

implicit val foo: String = "foo"

should also provide the same example right? If so, let's just keep it as simple as possible.

@tanishiking
Copy link
Contributor Author

if you have any feedback about the CONTRIBUTING.md please do let me know!

Overall, everything is very clear, and I could understand the workflow, great job 👍 !
One thing I wasn't sure about is when I hit The index will automatically build in CI, so you don't manually need to build it. However if you'd like to you can run the following command to rebuild it: I wasn't sure can I generate the index locally and commit it, or we shouldn't commit it manually and leave it for CI? (I guess either is fine?)

So the id should actually never be removed in Dotty (it actually can't since it will screw up all the numbering). Just for documentation purposes we should keep the IDs
I think it's a good idea just for documentation, plus if someone is using an older version of the compiler and they see an id that no longer exists, they'll still be able to look it up.

Gotcha, that makes sense :)

I've been thinking a bit about this lately and I think we might need to change the ErrorMessageID enum to somehow be able to have an active field or something that we can mark an ID as legacy.

That's a good idea, now dotty-error-index-side have to make sure the "legacy" errors are actually deprecated, but it would be maintainable if compiler has an information the error is still active or legacy.


Anyway, I'll tackle the review comments, and rebase on main :)

@ckipp01
Copy link
Owner

ckipp01 commented Apr 14, 2022

I wasn't sure can I generate the index locally and commit it, or we shouldn't commit it manually and leave it for CI? (I guess either is fine?)

Yup, exactly. Either is fine.

@tanishiking tanishiking force-pushed the 061-toplevelcantbe-implicit branch from 8151e96 to 1b147cd Compare April 14, 2022 08:49
.vscode/settings.json Outdated Show resolved Hide resolved
Adding `// LEGACY` to 061.
It seems like TopLevelCantBeImplicit is no longer the case thanks to
scala/scala3#5754

This is actually confirmed in https://github.com/lampepfl/dotty/blob/93fc41fcb624df73cc12d52b79d518a30a778a7c/tests/run/toplevel-implicits/a.b.scala#L19-L21
@tanishiking tanishiking force-pushed the 061-toplevelcantbe-implicit branch from 1b147cd to 7dcfe78 Compare April 14, 2022 08:51
Comment on lines 5 to 6
import scala.language.implicitConversions
implicit def intToBoolean(x: Int): Boolean = x != 0
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry if I wasn't clear in my message. I mean everything except the

implicit val foo: String = "foo"

can be removed so then this would just be

@main def TopLevelCantBeImplicitID = ()
implicit val foo: String = "foo"

Since that's the most minimal to illustrate the top level implicit right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right! I'll remove the implicit def part 👍

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even the import isn't needed though right? Since it's not doing anything?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yeah, it's now not needed!

@tanishiking tanishiking force-pushed the 061-toplevelcantbe-implicit branch 2 times, most recently from 94fe263 to e16a95d Compare April 14, 2022 09:14
@tanishiking tanishiking force-pushed the 061-toplevelcantbe-implicit branch from e16a95d to 49c6749 Compare April 14, 2022 09:14
Copy link
Owner

@ckipp01 ckipp01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks @tanishiking! If all work after this is merged the index should be updated as well. So we'll see!

@ckipp01 ckipp01 merged commit 9dbe73b into ckipp01:main Apr 14, 2022
@tanishiking
Copy link
Contributor Author

Looks like the CI works fine and the index is now updated 424de7d 🎉 cool!

@tanishiking tanishiking deleted the 061-toplevelcantbe-implicit branch April 14, 2022 09:37
@ckipp01
Copy link
Owner

ckipp01 commented Apr 18, 2022

o the id should actually never be removed in Dotty (it actually can't since it will screw up all the numbering). Just for documentation purposes we should keep the IDs, but the Message that uses that ID can be removed. I've been thinking a bit about this lately and I think we might need to change the ErrorMessageID enum to somehow be able to have an active field or something that we can mark an ID as legacy. I plan on digging into that as I get the sbt/zinc/problem stuff done. Any regarding keeping it in here, yea, I've been mimicking what they do in the rust one and they also keep legacy ones in there. I think it's a good idea just for documentation, plus if someone is using an older version of the compiler and they see an id that no longer exists, they'll still be able to look it up.

Just to tie these together I ended up doing this in scala/scala3#14965

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants