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

REPL :type multiple vals #7942

Closed
scabug opened this issue Oct 29, 2013 · 5 comments
Closed

REPL :type multiple vals #7942

scabug opened this issue Oct 29, 2013 · 5 comments
Labels

Comments

@scabug
Copy link

scabug commented Oct 29, 2013

Just trying to understand the type command in REPL.

Maybe there are still some corner cases. I did follow #7132.

scala> :type def i = 8
=> Int

scala> :type val i = 9
Int

scala> :type val i = 9 ; val j = 8
=> Int <and> => Int

scala> :type -v val i = 9 ; val j = 8
// Type signature
=> Int <and> => Int

// Internal Type structure
OverloadedType(
  alts = List(
    NullaryMethodType(
      TypeRef(TypeSymbol(final abstract class Int extends AnyVal))
    )
    NullaryMethodType(
      TypeRef(TypeSymbol(final abstract class Int extends AnyVal))
    )
  )
)
@scabug
Copy link
Author

scabug commented Oct 29, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7942?orig=1
Reporter: @som-snytt
Affected Versions: 2.11.0-M6
See #7132

@scabug
Copy link
Author

scabug commented Oct 29, 2013

@paulp said:
It should say "Slow down, turbo. One name at a time."

@scabug
Copy link
Author

scabug commented Oct 29, 2013

@som-snytt said:
My thinking is: if :type means "the types REPL would have reported, but without the side effect of execution," then it needs an $eval.$type to just collect those strings from the "member handlers". I don't know yet if that's really what it means. I'm still looking at the few uses of ExprTyper. I did find the impl of :type in the package object. Why doesn't everything go in the package object. That way, it's nicely packaged.

Your bon mot on the PR was "that's what we have a compiler for." In this case, "that's what we have the AST for", so I shouldn't have to do more than the usual wrapping to get the types of stuff.

@scabug
Copy link
Author

scabug commented Oct 29, 2013

@som-snytt said:
Feature idea, paste the last thing, including what I typed:

scala> :type val i = { println("hi"); 7 }
Int
// ok, that's what I want, go ahead and do it
scala> :paste -
hi
i: Int = 7

I thought it wasn't supposed to evaluate, by the way, so maybe I'm missing something in the nomenclature:

Welcome to Scala version 2.11.0-20131018-072258-54707cb450 (OpenJDK 64-Bit Server VM, Java 1.7.0_25).
Type in expressions to have them evaluated.
Type :help for more information.

scala> :type val i = { println("hi"); 7 }
hi
Int

@som-snytt
Copy link

The first issue progressed but not the last, which I will close as out of scope, together with "more unusual ways to paste code."

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

No branches or pull requests

3 participants