Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 09:36
    nicolasstucki synchronize #7245
  • 09:28
    nicolasstucki synchronize #7245
  • 09:11
    odersky synchronize #7245
  • 08:18
    liufengyun assigned #7220
  • 08:18
    liufengyun review_requested #7220
  • 08:15
    milessabin commented #7244
  • 08:10
    nicolasstucki unassigned #7245
  • 07:50
    nicolasstucki assigned #7245
  • 07:44
    nicolasstucki labeled #7244
  • 07:24
    odersky synchronize #7245
  • 07:21
    odersky synchronize #7245
  • 07:12
    odersky commented #7244
  • 06:55
    odersky synchronize #7245
  • 06:45
    odersky synchronize #7245
  • 04:16
    ashwinbhaskar commented #6626
  • 01:36
    ruhuansanmei starred lampepfl/dotty
  • Sep 17 23:05
    odersky synchronize #7245
  • Sep 17 22:07
    odersky synchronize #7245
  • Sep 17 21:26
    odersky synchronize #7245
Eric K Richardson
@ekrich
@som-snytt I added the flag but it didn't report anything.
@smarter The code diff I posted above reported a non-local return with a return inside an if and for. I am not sure what constitutes non-local.
Sébastien Doeraene
@sjrd
A for desugars into calls to map, foreach, etc. with lambda arguments. So your return actually ends up in a lambda.
Eric K Richardson
@ekrich
I thought so but wasn’t sure. Thanks!
Alex Simkin
@SimY4
Hello, everyone! Sorry if this question was already asked in this room, I'm working on some scala exercises using dotty and I'm trying to introduce a syntax for Option.map2[A, B, C](Option[A], Option[B])((A, B) => C): Option[C] my method definition looks like this: def (oa: Option[A]) map2[A, B, C](ob: Option[B])(f: (A, B) => C): Option[C] = ??? but it have some issues calling this method in a form of (o1 map2 o2)((a, b) => a + b). Dotty complains that map2 is not a member of type Option. This syntax, on the other hand, works fine def (t: (Option[A], Option[B])) map2[A, B, C](f: (A, B) => C): Option[C] = ???. Is this expected?
Lúcás Meier
@cronokirby
Is there a tool for automatic formatting of Dotty / Scala 3 code?
Lúcás Meier
@cronokirby
Is there a way to override toString on enums?

I have this code:

enum Reg:
  case EAX
  override def toString: String = "%eax"

But code that relies on it e.g. println(Reg.EAX) prints out "EAX" instead of the expected "%eax"

If you further extend the enum:

enum Reg:
  case EAX
  case Other(name: "string")
  override def toString: String = "%eax"

Then the following happens:

scala> println(Reg.EAX)
EAX

scala> println(Reg.Other("foo"))
%eax

I think the abstraction around enums is leaking a bit here...

Guillaume Martres
@smarter
@SimY4 I think your parens might not do what you want, try writing o1.map2(o2)((a, b) => a + b))
@cronokirby hmm that might be a bug
Lúcás Meier
@cronokirby
should I raise an issue?
Guillaume Martres
@smarter
yes
Lúcás Meier
@cronokirby
> case class A(arg: Unit)
> A(())

This should be valid code right?

I get a very weird error in the REPL: https://gist.github.com/cronokirby/7a81cd0be399ea7037606728257daab7
java.lang.VerifyError

Guillaume Martres
@smarter
there's an open issue for that: lampepfl/dotty#6987
Jamie Willis
@J-mie6
So I'm just trying out the new dotty release with the 2.13 standard library
if I run this code which adds 10 million numbers to a list buffer (something which was fine before)
for (i <- 0 until 10000000) lb += i
I get a Heap overflow
GC overhead limit exceeded
any ideas what that might be?
it's not actually even consuming much memory!
Jamie Willis
@J-mie6
it could be SBT I suppose, first time Ive ran it in the terminal
Alex Simkin
@SimY4

@smarter not working this way either

[error] 14 |    o1.map2(o2)(_ + _) == o2.map2(o1)(_ + _)
[error]    |    ^^^^^^^
[error]    |    value map2 is not a member of cp4.Chapter4.Option[Int]

my map2 definition

    def (oa: Option[A]) map2[A, B, C](ob: Option[B])(f: (A, B) => C): Option[C] = 
      (oa, ob) match {
        case (Some(a), Some(b)) => Some(f(a, b))
        case _ => None
      }
Alex Simkin
@SimY4
I suspect that it doesn't like two parameter lists. Say, if I define a filter def (oa: Option[A]) filter[A] (p: A => Boolean): Option[A] = ??? it'll work fine.
Alex Simkin
@SimY4
Ok, so apparently the problem was that I had another map2 method in scope with a similar signature def (ea: Either[E, A]) map2[E, A, B, C](eb: Either[E, B])(f: (A, B) => C): Either[E, C] = ??? and that caused an issue. But the error was a bit misleading.
Abel Nieto
@abeln
Is the dotty community build part of the CI? Are those libraries being kept up to the date w.r.t to e.g. syntax changes in dotty?
Abel Nieto
@abeln
Related question: what's the best way to run the community build with -Yexplicit-nulls turned on?
i.e. is there a way to pass extra flags to the community build tests?
@nicolasstucki who I think has been maintaining some of the CB tests
nafg
@nafg
The comments here suggest to me that significant indentation would disastrous https://www.reddit.com/r/programming/comments/d50w20/stack_overflow_trends_scalas_decline_mirrors/
is there any way I can convince someone that we're focusing on the wrong things?
Ihor Antonov
@ngortheone
Hey guys, I want to try dotty with vim. I have LSP Client plugin. How do I start Dotty Language server?
Guillaume Martres
@smarter
@ngortheone There's instructions on using vim at https://duhemm.github.io/2018/12/01/using-vim-and-dotty-language-server.html
so you could try adding set scalacOptions in ThisBuild += "-Yexplicit-nulls"
Michał Gutowski
@CucumisSativus

When compiling

try {
  2 /0 
} catch {
  case a: ArithmeticException => println("arithemtic")
  case NonFatal(e) => println("non fatal")
}

We get the following code after TryCatchPatterns

  try 
    {
      {
        2./(0)
        ()
      }
    }
   catch 
    {
      case a @ _:ArithmeticException => 
        println("arithemtic")
      case ex1 @ _ => 
        matchResult1[Unit]: 
          {
            case val x1: Throwable(ex1) = ex1
            if x1.ne(null) then 
              {
                case val x2: Option[Throwable] = 
                  util.control.NonFatal.unapply(x1)
                if x2.isEmpty.unary_! then 
                  {
                    case val x3: Throwable = x2.get
                    case val e: Throwable = x3
                    return[matchResult1] 
                      {
                        println("non fatal")
                      }
                  }
                 else ()
              }
             else ()
            throw ex1
          }
    }
}

why are x3 and e variables even created? Why does .get create new variable?\

Guillaume Martres
@smarter
because the compiler doesn't do any DCE
and the pattern matcher phase doesn't generate as efficient code as it could
although, when you write case NonFatal(e) =>, I would expect e to be in scope, that could be useful in a debugging session
case NonFatal(_) => should avoid that (but doesn't currently, patches welcome: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala)
Abel Nieto
@abeln
@smarter thanks!
Sergii
@SergiiVlasiuk
Which ide do i need for dotty? Does Eclipse support it?
Ashwin Bhaskar
@ashwinbhaskar

Is there a way to see in which phase the dotty compiler got an error? doing a dotc -help gives option of `explain. But explain only elaborates the error message. It does not tell at which exact compilation failed. For example

dotc experiments/DoWhileTest.scala -explain
-- [E050] Reference Error: experiments/DoWhileTest.scala:4:8 -------------------

But I would like to see where this failed - in Typer or Phase or something else

Georgi Krastev
@joroKr21
Hi, a question about tasty reflect. Is there any way to inspect all members of a type?
For context, I'm looking into porting https://typelevel.org/cats-tagless/ to dotty
Henry Story
@bblfish
I have a state monad case class State[S, +A](run: S => (A,S))
Is there a way to declare the state as non funcitonal such as MutatingState[A] = State(run: S => (A, S.type)) ?
Ie a state mondas where the object S is mutating?
Henry Story
@bblfish
I'll try something like this
trait State[S,+A] {  def run(s: S): (A,S) }
trait MutatingState[S,+A] extends State[S,A] { def run(s: S): (A,s.type) }