Skip to content

Block add a pair of brackets unexpectly. #6696

Closed

Description

@scabug
Welcome to Scala version 2.10.0-RC2 (Java HotSpot(TM) Client VM, Java 1.7.0_09).

Type in expressions to have them evaluated.
Type :help for more information.

scala> import reflect.runtime.universe._
import reflect.runtime.universe._

scala> Block(Ident("foo"))
res0: reflect.runtime.universe.Block =
{
  foo;
  ()
}

The pair of brackets change the result type to Unit, and I want it just be a foo.

Activity

  1. scabug commented on Nov 21, 2012

    @scabug
    Author

    Imported From: https://issues.scala-lang.org/browse/SI-6696?orig=1
    Reporter: @Atry
    Affected Versions: 2.10.0-RC2

  2. scabug commented on Nov 21, 2012

    @scabug
    Author

    @retronym said (edited on Nov 21, 2012 8:30:17 AM UTC):
    Eugene: is this intentional?

    {code:title=src/reflect/scala/reflect/internal/Trees.scala}
    /** Block factory that flattens directly nested blocks.
    /
    def Block(stats: Tree
    ): Block = {
    if (stats.isEmpty) Block(Nil, Literal(Constant(())))
    else stats match {
    case Seq(b @ Block(_, )) => b
    case Seq(stat) => Block(stats.toList, Literal(Constant(())))
    case Seq(
    , rest @ _*) => Block(stats.init.toList, stats.last)
    }
    }
    {code}

  3. scabug commented on Nov 21, 2012

    @scabug
    Author

    @xeno-by said:
    @杨博: Use Block(Nil, Ident("foo")) instead.

    @jason: It looks like we need to jettison all the "helper" tree factory methods I exposed from the compiler. Ident("foo") without explicitly specifying newTermName gives me shivers.

  4. scabug commented on Nov 21, 2012

    @scabug
    Author

    @xeno-by said:
    I'm closing this issue, because it's not a bug per se, just a problem with misleading methods that made it to the public API.

  5. scabug commented on Nov 21, 2012

    @scabug
    Author
  6. added this to the 2.10.1 milestone on Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions