Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block add a pair of brackets unexpectly. #6696

Closed
scabug opened this issue Nov 21, 2012 · 5 comments
Closed

Block add a pair of brackets unexpectly. #6696

scabug opened this issue Nov 21, 2012 · 5 comments
Assignees
Milestone

Comments

@scabug
Copy link

@scabug scabug commented Nov 21, 2012

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.

@scabug
Copy link
Author

@scabug scabug commented Nov 21, 2012

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

Loading

@scabug
Copy link
Author

@scabug scabug commented Nov 21, 2012

@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}

Loading

@scabug
Copy link
Author

@scabug scabug commented Nov 21, 2012

@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.

Loading

@scabug
Copy link
Author

@scabug scabug commented Nov 21, 2012

@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.

Loading

@scabug scabug closed this Nov 21, 2012
@scabug
Copy link
Author

@scabug scabug commented Nov 21, 2012

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants