question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

REPL breaks when complicated type is inferred

See original GitHub issue

I was trying to investigate something about how dotty infers types that scalac infers as existential “forSome” types. Alas the REPL only shows me an error that seems to come from the code generation phase of the REPL itself.

scala> 
object foo { 
    trait ShapeLevel 
    trait FlatShapeLevel extends ShapeLevel 
    trait ColumnsShapeLevel extends FlatShapeLevel 
   
    abstract class Shape[Level <: ShapeLevel, -Mixed, Unpacked, Packed] 
    object Shape extends TupleShapeImplicits { } 
    trait TupleShapeImplicits { 
      implicit final def tuple2Shape[Level <: ShapeLevel, M1,M2, U1,U2, P1,P2](implicit u1: Shape[_ <: Level, M1, U1, P1], u2: Shape[_ <: Level, M2, U2, P2]): Shape[Level, (M1,M2), (U1,U2), (P1,P2)] = ??? 
    } 
  } 
defined module foo
scala> import foo._ 
import foo._
scala> implicit val shape: Shape[_ <: FlatShapeLevel, Int, Int, _] = null 
val shape: foo.Shape[_ <: foo.FlatShapeLevel, Int, Int, _] = null
scala> def hint = Shape.tuple2Shape(shape, shape) 
-- Error: <console>:4:4 --------------------------------------------------------
4 |(""+"def hint: foo.Shape[foo.FlatShapeLevel, (Int, Int), (Int, Int), (shape.Packed, 
  |    ^
  |    unclosed string literal
-- [E039] Syntax Error: <console>:6:1 ------------------------------------------
6 |)]\n"
  | ^
  | ';' expected, but `Packed` found

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
felixmuldercommented, May 28, 2017

Thanks for reporting @Jasper-M! We will shortly be reimplementing the REPL from scratch. Hopefully, this won’t rear its ugly head in the new shiny version! 😃

0reactions
felixmuldercommented, Aug 25, 2017

See #3020, there was still an issue with how the types were printed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Oh that nice! - Replit
This is not a dynamically typed language, but the type is inferred. That means that Rust understood x should be an integer.
Read more >
Noughts & Crosses Game in 69 lines of Python code - Replit
If the while loop doesn't encounter a break on its way, it means that the 9 moves are made, yet no one won,...
Read more >
Error when creating new React Typescript project - Replit
Property 'a' must be of type 'DetailedHTMLProps ', but here has type 'DetailedHTMLProps '. I have changed nothing in the ... Cannot infer...
Read more >
@laksh5teach https://repl.it... - Replit
This tutorial is fairly simple, with some complex concepts to it. ... Cannot infer image mime type ... If not, it breaks the...
Read more >
Types and readability
Then, so long as it's not too complicated, it might be able to work out the type for me. I can run the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found