Skip to content

undoTo gets head of empty list #3

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

Closed
scabug opened this issue Aug 28, 2007 · 2 comments
Closed

undoTo gets head of empty list #3

scabug opened this issue Aug 28, 2007 · 2 comments
Assignees

Comments

@scabug
Copy link

scabug commented Aug 28, 2007

Aladdin: [http://scala-webapps.epfl.ch/bugtracking/bugs/displayItem.do?id=1297 bug 1297]

== Code ==

adriaan-moors-computer:~ adriaan$$ ledit ~/src/scala/trunk/build/quick/bin/scala
Welcome to Scala version 2.6.0.12630.20070822-153214.
Type in expressions to have them evaluated.
Type :help for more information.

scala> def foo[A, B, C](l: List[A], f: A => B=>B, g: B=>B=>C): List[C] = l map (g compose f)

== What happened ==

Exception in thread "main" java.util.NoSuchElementException: head of empty list
        at scala.Nil$$.head(List.scala:1193)
        at scala.Nil$$.head(List.scala:1190)
        at scala.tools.nsc.symtab.Types$$class.undoTo(Types.scala:2726)
        at scala.tools.nsc.symtab.Types$$class.isSubType(Types.scala:2888)
        at scala.tools.nsc.symtab.SymbolTable.isSubType(SymbolTable.scala:11)
        at scala.tools.nsc.symtab.Types$$Type.$$less$$colon$$less(Types.scala:469)
        at scala.tools.nsc.symtab.Types$$class.isSubArgs$$0(Types.scala:2950)
        at scala.tools.nsc.symtab.Types$$class.isSubArgs$$0(Types.scala:2951)
        at scala.tools.nsc.symtab.Types$$class.isSubType0(Types.scala:2955)
        at scala.tools.nsc.symtab.Types$$class.isSubType(Types.scala:2886)
        at scala.tools.nsc.symtab.SymbolTable.isSubType(SymbolTable.scala:11)
        at scala.tools.nsc.symtab.Types$$Type.$$less$$colon$$less(Types.scala:469)
        at scala.tools.nsc.typechecker.Infer$$Inferencer.isCompatible(Infer.scala:360)
        at scala.tools.nsc.typechecker.Infer$$Inferencer.isWeaklyCompatible(Infer.scala:364)
        at scala.tools.nsc.typechecker.Infer$$Inferencer.protoTypeArgs(Infer.scala:437)
        at scala.tools.nsc.typechecker.Typers$$Typer.doTypedApply(Typers.scala:1601)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedApply$$0(Typers.scala:2276)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed1(Typers.scala:2836)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:2938)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedArg(Typers.scala:1497)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedArgToPoly$$0(Typers.scala:1606)
        at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$69.apply(Typers.scala:1615)
        at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$69.apply(Typers.scala:1615)
        at scala.List$$.map2(List.scala:277)
        at scala.tools.nsc.typechecker.Typers$$Typer.doTypedApply(Typers.scala:1615)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedApply$$0(Typers.scala:2276)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed1(Typers.scala:2836)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:2938)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:2982)
        at scala.tools.nsc.typechecker.Typers$$Typer.transformedOrTyped(Typers.scala:3031)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedDefDef(Typers.scala:1241)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed1(Typers.scala:2679)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:2938)
        at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:2971)
        at scala.tools.nsc.typechecker.Typers$$Typer.typedStat$$0(Typers.scala:1463)
        at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$57.apply(Typers.scala:1493)
        at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$57.apply(Typers.scala:1493)
        at scala.List$$.loop$$0(List.scala:244)
        at scala.List$$.mapConserve(List.scala:261)

What expected

no exception (if I uncomment my change to undoTo, the crash disappears, but it does not type check) Burak pointed out why it doesn't type check.. this works fine (i.e. no type error and no crash):

def foo[A, B, C](l: List[A], f: A => B=>B, g: (B=>B)=>C): List[C] = l map (g compose f)

@scabug
Copy link
Author

scabug commented Aug 28, 2007

Imported From: https://issues.scala-lang.org/browse/SI-3?orig=1
Reporter: @adriaanm

@scabug
Copy link
Author

scabug commented Jan 14, 2009

@odersky said:
Milestone 2.6.0 deleted

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

No branches or pull requests

2 participants