Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Nov 26 18:51
    som-snytt labeled #12501
  • Nov 26 18:21
    som-snytt opened #12501
  • Nov 26 16:02
    arata-honda synchronize #2235
  • Nov 26 01:08
    arata-honda synchronize #2235
  • Nov 26 01:02
    arata-honda commented #2235
  • Nov 26 00:59
    arata-honda commented #2235
  • Nov 26 00:58
    arata-honda synchronize #2235
  • Nov 25 20:58
    joshlemer commented #1256
  • Nov 25 18:04
    eed3si9n commented #2235
  • Nov 25 17:58
    joshlemer commented #1256
  • Nov 25 17:53
    joshlemer commented #1306
  • Nov 25 17:53
    joshlemer closed #1306
  • Nov 25 17:50
    joshlemer commented #1306
  • Nov 25 17:49
    joshlemer labeled #1306
  • Nov 25 17:49
    joshlemer opened #1306
  • Nov 25 15:12
    SethTisue unlabeled #9814
  • Nov 25 15:12
    SethTisue labeled #9814
  • Nov 25 10:55
    olafurpg commented #12500
  • Nov 25 10:54
    olafurpg commented #12500
  • Nov 25 10:38
    lrytz commented #9807
Guillaume Martres
@smarter
that would be unsound
since nothing prevents the callee from writing F[SomeThingThatDoesntExtendFoo]
Ghost
@ghost~5fac9159d73408ce4ff3d745
There were two unfortunate asInstanceOf[Array[T]] overnight.
Rob Norris
@tpolecat
Rough night?
Jasper Moeys
@Jasper-M

that would be unsound

True unfortunately. For some reason I see it come up more often when trying funny things with poly functions. Feels like there should be some way to abstract over the bounds

Bill Venners
@bvenners
Say, I remember the discussion of commas and with and dropping new included a discussion of what would happen to new SomeClass with SomeTrait expressions. I.e., expressions where in Scala 2 we can get an instance of an anonymous class that mixes in one or more traits. That exact expression still works, but new SomeClass, SomeTrait does not work. Is the plan to over time drop this in favor of some other expression (such as a named object), or is the idea that new A with B with C will stay around?
jeremyrsmith
@jeremyrsmith
Hey, I made a very small docs PR based on something that confused me (specifically, implementing a Haskell-style $ operator — whether or not that's a good idea — works when the docs seem to imply it won't). No big deal, just wanted to bump that as I'm not sure anyone is actively watching that repo (or maybe the current 2-3 transition is not a great time for such things) scala/docs.scala-lang#2044
Dmitrii Naumenko
@unkarjedy

Hi!
Can anyone give an insight for what purpocesscala-asm is required in the Scala 3 compiler classpath?

org.scala-lang.modules:scala-asm:jar:9.1.0-scala-1

Looks like if I remove it, simple projects are still compiled fine

Guillaume Martres
@smarter
The backend uses it
Same as scala 2
It must still be on the jvm classpath somehow if you can compile stuff
Ghost
@ghost~5fac9159d73408ce4ff3d745
@jeremyrsmith I commented that dollar and underscore are listed as letters. I just verified that Scala 2 allows def of backticked underscore, but Scala 3 is lagging in that department.
twitter commented about grouped vs unrolled import syntax (and diffs). I haven't looked up the old discussions about improving import syntax to be tree-like in some form. But they also mentioned too bad Scala 3 requires braces. Did import collection: ever come up, for import collection.{?
Ghost
@ghost~5fac9159d73408ce4ff3d745
Oh actually I came to gitter because of def f = { def g = ??? ; g } idiom where g is many LOC. Instead of a comment // begin f at the invocation of g, I would actually like a way to use the end marker. Now, end f already hints that the call to g is the body of f, but it would be great if there were syntax. end f = g is not that syntax, but something similar to make the intention clear. Maybe I'm asking for begin f: which enforces that preceding body is only local defs; you could imagine using locally that way, or call it body; but probably don't want to indent it. They're right, coding is hard.
jeremyrsmith
@jeremyrsmith
@som-snytt thanks for the comments – maybe the right solution is for the syntax specification to be part of the docs? I dunno. Either way, I think the "(all letters)" thing deserves a mention that _ and $ are specifically considered letters, as long as it's nowhere else in the accessible docs. If it were in the docs, a better solution might be for (all letters) to be a link to the specification of what "letters" means...
But, $ and _ don't obviously seem like letters to me (nor most people, I imagine) so it's worth mentioning somewhere in the docs that they are letters (for certain purposes)
(FWIW I have no idea whether this is still a thing in Scala 3... was just thinking about the docs as they exist now)
jeremyrsmith
@jeremyrsmith
I mean the real issue is the top thing which says "(all characters not mentioned below)" as the highest priority in operator precedence. Maybe it would be better to precisely specify what those are. Especially given that : has a whole other special behavior... 🤷‍♂️ just thought a very small doc change might be helpful there anyway
and FWIW I understand that there are many reasons why a haskell-style $ operator isn't a great idea in Scala... e.g. fn1 andThen fn2 andThen fn3 $ arg. Whether or not it's a good idea, the confusion is that the current docs seem to imply it wouldn't work because $ would have higher precedence than andThen, if you don't think of $ as a letter.
jeremyrsmith
@jeremyrsmith
But it turns out that $ is a special case of "letter", which is not super intuitive. So it seems like it wouldn't hurt to mention that, somewhere in docs.scala-lang.org¯_(ツ)_/¯
Jason Zaugg
@retronym
Scala 2.12.14 is now available. This is a maintainance release in the Scala 2.12.x series. Details: https://github.com/scala/scala/releases/tag/v2.12.14
Tomasz Godzik
@tgodzik

@smarter how would you go around finding a symbol with given name in the current scopes using the Scala 3 presentation compiler? We have two ways in Metals currently and none of them seem to work perfectly.

A very basic one we are using for Hover is ctx.findRef method here: https://github.com/scalameta/metals/blob/main/mtags/src/main/scala-3/scala/meta/internal/mtags/VersionSpecificEnrichments.scala#L15
But that seem to not find any values from the scope. Is there any correct way of doing it or are the information not available anywhere?

The test case I am trying to fix is https://github.com/scalameta/metals/blob/main/tests/cross/src/test/scala/tests/pc/InsertInferredTypeSuite.scala#L329 <- we try to automatically fix the import in case of conflicts

We also try to build the names cache here (based on the compiler code) https://github.com/scalameta/metals/blob/main/mtags/src/main/scala-3/scala/meta/internal/pc/NamesInScope.scala#L60 however I wonder if we should try to fix that or is there a better way?

None of the two find values defined in current scope.
Guillaume Martres
@smarter
@tgodzik findRef is not going to work outside of the Typer phase. dotty.tools.dotc.interactive.Completion.Completer recomputes scoping information for interactive usages, you should reuse/extend that: https://github.com/lampepfl/dotty/blob/88a5779e3d3251662c0de9887b64217171d5b9b5/compiler/src/dotty/tools/dotc/interactive/Completion.scala#L156-L169
Tomasz Godzik
@tgodzik
@smarter Thanks for confirming!
Ghost
@ghost~5fac9159d73408ce4ff3d745
When they add pragmas for conditional compilation, please make sure it expresses "before bootstrap" and "after bootstrap".
Ghost
@ghost~5fac9159d73408ce4ff3d745
@som-snytt actually there's a dotty " treat non-bootstrapped compiler as
experimental-friendly. The motivation is to compile
the standard library with experimental features enabled
at all times."
Eric K Richardson
@ekrich

Should relaxing this warning in 2.13 be considered based on the direction suggested in Scala 3 for enums below?

[info] compiling 34 Scala sources to /Users/eric/workspace/sjavatime/sjavatime/js/target/scala-2.13/classes ...
[warn] /Users/eric/workspace/sjavatime/sjavatime/shared/src/main/scala/java/time/LocalDate.scala:408:23: Auto-application to `()` is deprecated. Supply the empty argument list `()` explicitly to invoke method values,
[warn] or remove the empty argument list from its definition (Java-defined methods are exempt).
[warn] In Scala 3, an unapplied method like this will be eta-expanded into a function.
[warn]     val month = Month.values.takeWhile(_.firstDayOfYear(leap) <= dayOfYear).last
[warn]                       ^
[warn] /Users/eric/workspace/sjavatime/sjavatime/shared/src/main/scala/java/time/LocalDate.scala:408:23: Auto-application to `()` is deprecated. Supply the empty argument list `()` explicitly to invoke method values,
[warn] or remove the empty argument list from its definition (Java-defined methods are exempt).
[warn] In Scala 3, an unapplied method like this will be eta-expanded into a function.
[warn]     val month = Month.values.takeWhile(_.firstDayOfYear(leap) <= dayOfYear).last
[warn]                       ^
[warn] one warning found

lampepfl/dotty#11248

Oron Port
@soronpo
enum Color:
  case Red, Green, Blue

When I print the code after pickling, I noticed that the companion Color extends scala.deriving.Mirror.Sum.
However, the following does not pass typecheck:

val x: scala.deriving.Mirror.Sum = Color

Is there a reason for this? I would like to create an extension method that works on enum companion objects, and I would rather have a more narrow upper-bound instead of Any.

nafg
@nafg
This message was deleted
sinanspd
@sinanspd
Are there any examples/documentation of ResearchPlugin ? Especially on using them to extending the parser and/or type checker? I can not find anything on them other than a page that says "Research Plugins can do this"
Princess | April
@NthPortal
why do collections not have a specificFactory: Factory[A, C] method? it would match fromSpecificIterable well
Li Haoyi
@lihaoyi
Does anyone know if Future#zip being asymmetric in the case of failure is intentional? e.g. given val f3 = f1.zip(f2), if f1 fails and f2 is still running then f3 fails immediately, whereas if f2 fails and f1 is still running then f3 keeps running
the ordering of who-zips-who seems like something that shouldn't matter, but in this case definitely does if I want to e.g. bail out ASAP to report a failure to a user
Sébastien Doeraene
@sjrd
It's probably not intentional. I wouldn't be surprised if it even depends on the version of Scala.
zip should be symmetric.
Li Haoyi
@lihaoyi
looking at the implementation, it's because it's implemented using flatMap, which is naturally asymmetric
should be pretty easy to fix by implementing it using promises I think
Li Haoyi
@lihaoyi
seems like they're all implemented using zipWith
Martijn
@martijnhoekstra:matrix.org
[m]
I wonder whether anyone depends on the behaviour of a.zip(b) running until a finishes and whether you can reasonably call that a bug to be fixed rather than a semantic change
Li Haoyi
@lihaoyi
possibly, but it seems like something that's unlikely to be reliable enough to depend upon. It's not like people know the total ordering of how long their Futures take to run and then ensure they're in the right order before ziping or sequenceing them together
Martijn
@martijnhoekstra:matrix.org
[m]
It's not so unlikely to me there is code out there that makes assumptions like a.zip(b).onComplete(/* assumes a is complete */)Maybe not unlikely enough or broken enough not to stand in in the way of a fix, but still not so unlikely to not take it along as a consideration
Li Haoyi
@lihaoyi
I'll open a PR and include this as a consideration
Li Haoyi
@lihaoyi
here's the strawman PR scala/scala#9655
Jamie Thompson
@bishabosha
enum Color:
  case Red, Green, Blue

When I print the code after pickling, I noticed that the companion Color extends scala.deriving.Mirror.Sum.
However, the following does not pass typecheck:

val x: scala.deriving.Mirror.Sum = Color

Is there a reason for this? I would like to create an extension method that works on enum companion objects, and I would rather have a more narrow upper-bound instead of Any.

@soronpo Mirror parent classes are added to companion objects after type checking, I assume as it is only meant to be an optimisation - the API for mirrors is meant to only be accessed through implicit search

Oron Port
@soronpo
Oron Port
@soronpo
What is the reason enumeration cases cannot have bodies?
Diego E. Alonso Blas
@diesalbla
@soronpo Are you referring to the new Scala 3 enum?
Oron Port
@soronpo
Yes
sinanspd
@sinanspd
At what stage of the compilation are the mixins actually evaluated ?
If I am introducing new syntax to the compiler that "generates" a new type similar to with in A with B, can I safely ignore the occurrence of this inside case class parameters and use the existing paramClauses() and classDef() to parse ? Ideally I would like to address the syntax in the Desugar phase but it seems like case classes go through so much processing that I am not really sure anymore
(assume that the tokens and scanner have been updated to read this syntax)