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

Compiler crashes while normalizing function prototypes with more than 30 parameters. #1543

Closed
nicolasstucki opened this issue Sep 27, 2016 · 2 comments
Assignees

Comments

@nicolasstucki
Copy link
Contributor

Note: Currently function classes go up to 30 in dotty as a quick fix.

class Bar {
  def foo(p1: Int, p2: Int, p3: Int, p4: Int, p5: Int, p6: Int, p7: Int, p8: Int, p9: Int, p10: Int, p11: Int, p12: Int, p13: Int, p14: Int, p15: Int, p16: Int, p17: Int, p18: Int, p19: Int, p20: Int, p21: Int, p22: Int, p23: Int, p24: Int, p25: Int, p26: Int, p27: Int, p28: Int, p29: Int, p30: Int, p31: Int): Int = 42
  new Bar().foo(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31)
}
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 31
    at dotty.tools.dotc.core.Definitions$FunctionOf$.apply(Definitions.scala:545)
    at dotty.tools.dotc.typer.ProtoTypes$$anonfun$normalize$1.apply(ProtoTypes.scala:401)
    at dotty.tools.dotc.typer.ProtoTypes$$anonfun$normalize$1.apply(ProtoTypes.scala:387)
    at dotty.tools.dotc.util.Stats$.track(Stats.scala:36)
    at dotty.tools.dotc.typer.ProtoTypes$.normalize(ProtoTypes.scala:386)
    at dotty.tools.dotc.typer.ProtoTypes$Compatibility$class.normalizedCompatible(ProtoTypes.scala:43)
    at dotty.tools.dotc.typer.Typer.normalizedCompatible(Typer.scala:60)
    at dotty.tools.dotc.typer.ProtoTypes$SelectionProto.dotty$tools$dotc$typer$ProtoTypes$SelectionProto$$qualifies$1(ProtoTypes.scala:99)
    at dotty.tools.dotc.typer.ProtoTypes$SelectionProto.isMatchedBy(ProtoTypes.scala:101)
    at dotty.tools.dotc.core.TypeComparer.isMatchedByProto(TypeComparer.scala:972)
    at dotty.tools.dotc.core.TypeComparer.dotty$tools$dotc$core$TypeComparer$$firstTry(TypeComparer.scala:227)
    at dotty.tools.dotc.core.TypeComparer$$anonfun$isSubType$1.apply$mcZ$sp(TypeComparer.scala:132)
    at dotty.tools.dotc.core.TypeComparer$$anonfun$isSubType$1.apply(TypeComparer.scala:124)
    at dotty.tools.dotc.core.TypeComparer$$anonfun$isSubType$1.apply(TypeComparer.scala:124)
    at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:155)
    at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:56)
    at dotty.tools.dotc.core.TypeComparer.isSubType(TypeComparer.scala:123)
    at dotty.tools.dotc.core.TypeComparer.topLevelSubType(TypeComparer.scala:117)
    at dotty.tools.dotc.core.Types$Type$$anonfun$$less$colon$less$1.apply$mcZ$sp(Types.scala:693)
    at dotty.tools.dotc.core.Types$Type$$anonfun$$less$colon$less$1.apply(Types.scala:693)
    at dotty.tools.dotc.core.Types$Type$$anonfun$$less$colon$less$1.apply(Types.scala:693)
    at dotty.tools.dotc.util.Stats$.track(Stats.scala:36)
    at dotty.tools.dotc.core.Types$Type.$less$colon$less(Types.scala:692)
    at dotty.tools.dotc.core.Types$Type.relaxed_$less$colon$less(Types.scala:722)
    at dotty.tools.dotc.typer.ProtoTypes$Compatibility$class.isCompatible(ProtoTypes.scala:38)
    at dotty.tools.dotc.typer.Typer.isCompatible(Typer.scala:60)
    at dotty.tools.dotc.typer.ProtoTypes$Compatibility$class.constrainResult(ProtoTypes.scala:62)
    at dotty.tools.dotc.typer.Typer.constrainResult(Typer.scala:60)
    at dotty.tools.dotc.typer.Applications$Application.init(Applications.scala:183)
    at dotty.tools.dotc.typer.Applications$TypedApply.<init>(Applications.scala:439)
    at dotty.tools.dotc.typer.Applications$ApplyToTyped.<init>(Applications.scala:527)
    at dotty.tools.dotc.typer.Applications$$anonfun$realApply$1$1.dotty$tools$dotc$typer$Applications$class$$anonfun$$simpleApply$1(Applications.scala:572)
    at dotty.tools.dotc.typer.Applications$$anonfun$realApply$1$1$$anonfun$apply$5.apply(Applications.scala:597)
    at dotty.tools.dotc.typer.Applications$$anonfun$realApply$1$1$$anonfun$apply$5.apply(Applications.scala:597)
    at dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:1587)
    at dotty.tools.dotc.typer.Applications$$anonfun$realApply$1$1.apply(Applications.scala:598)
    at dotty.tools.dotc.typer.Applications$$anonfun$realApply$1$1.apply(Applications.scala:544)
    at dotty.tools.dotc.util.Stats$.track(Stats.scala:36)
    at dotty.tools.dotc.typer.Applications$class.realApply$1(Applications.scala:544)
    at dotty.tools.dotc.typer.Applications$class.typedApply(Applications.scala:641)
    at dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:60)
    at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1462)
    at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1503)
    at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1513)
    at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1511)
    at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:155)
    at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:56)
    at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1511)
    at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:1550)
    at dotty.tools.dotc.typer.Typer$$anonfun$typedSelect$1.dotty$tools$dotc$typer$Typer$$anonfun$$asSelect$1(Typer.scala:368)
    at dotty.tools.dotc.typer.Typer$$anonfun$typedSelect$1.apply(Typer.scala:407)
    at dotty.tools.dotc.typer.Typer$$anonfun$typedSelect$1.apply(Typer.scala:366)
    at dotty.tools.dotc.util.Stats$.track(Stats.scala:36)
    at dotty.tools.dotc.typer.Typer.typedSelect(Typer.scala:366)
    at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1442)
    at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1501)
    at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1513)
    at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1511)
    at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:155)
    at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:56)
    at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1511)
    at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:1550)
    at dotty.tools.dotc.typer.Applications$$anonfun$realApply$1$1.apply(Applications.scala:546)
    at dotty.tools.dotc.typer.Applications$$anonfun$realApply$1$1.apply(Applications.scala:544)
    at dotty.tools.dotc.util.Stats$.track(Stats.scala:36)
    at dotty.tools.dotc.typer.Applications$class.realApply$1(Applications.scala:544)
    at dotty.tools.dotc.typer.Applications$class.typedApply(Applications.scala:641)
    at dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:60)
    at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1462)
    at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1503)
    at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1513)
    at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1511)
    at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:155)
    at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:56)
    at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1511)
    at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:1541)
    at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:1546)
    at dotty.tools.dotc.typer.Typer$$anonfun$typedClassDef$1.apply(Typer.scala:1264)
    at dotty.tools.dotc.typer.Typer$$anonfun$typedClassDef$1.apply(Typer.scala:1212)
    at dotty.tools.dotc.util.Stats$.track(Stats.scala:36)
    at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:1212)
    at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1453)
    at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1501)
    at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1513)
    at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1511)
    at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:155)
    at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:56)
    at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1511)
    at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:1535)
    at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:1546)
    at dotty.tools.dotc.typer.Typer$$anonfun$typedPackageDef$1.apply(Typer.scala:1378)
    at dotty.tools.dotc.typer.Typer$$anonfun$typedPackageDef$1.apply(Typer.scala:1369)
    at dotty.tools.dotc.util.Stats$.track(Stats.scala:36)
    at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:1369)
    at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1491)
    at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1503)
    at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1513)
    at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1511)
    at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:155)
    at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:56)
    at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1511)
    at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:1550)
    at dotty.tools.dotc.typer.FrontEnd$$anonfun$typeCheck$1.apply$mcV$sp(FrontEnd.scala:47)
    at dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:23)
    at dotty.tools.dotc.typer.FrontEnd.typeCheck(FrontEnd.scala:45)
    at dotty.tools.dotc.typer.FrontEnd$$anonfun$runOn$3.apply(FrontEnd.scala:69)
    at dotty.tools.dotc.typer.FrontEnd$$anonfun$runOn$3.apply(FrontEnd.scala:69)
    at scala.collection.immutable.List.foreach(List.scala:381)
    at dotty.tools.dotc.typer.FrontEnd.runOn(FrontEnd.scala:69)
    at dotty.tools.dotc.Run$$anonfun$compileUnits$1$$anonfun$apply$mcV$sp$1.apply(Run.scala:69)
    at dotty.tools.dotc.Run$$anonfun$compileUnits$1$$anonfun$apply$mcV$sp$1.apply(Run.scala:66)
    at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
    at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:186)
    at dotty.tools.dotc.Run$$anonfun$compileUnits$1.apply$mcV$sp(Run.scala:66)
    at dotty.tools.dotc.Run$$anonfun$compileUnits$1.apply(Run.scala:60)
    at dotty.tools.dotc.Run$$anonfun$compileUnits$1.apply(Run.scala:60)
    at dotty.tools.dotc.util.Stats$.monitorHeartBeat(Stats.scala:69)
    at dotty.tools.dotc.Run.compileUnits(Run.scala:60)
    at dotty.tools.dotc.Run.compileSources(Run.scala:57)
    at dotty.tools.dotc.Run.compile(Run.scala:41)
    at dotty.tools.dotc.Driver.doCompile(Driver.scala:26)
    at dotty.tools.dotc.Driver.process(Driver.scala:124)
    at dotty.tools.dotc.Driver.process(Driver.scala:93)
    at dotty.tools.dotc.Driver.process(Driver.scala:105)
    at dotty.tools.dotc.Driver.main(Driver.scala:132)
    at dotty.tools.dotc.Main.main(Main.scala)

@DarkDimius
Copy link
Member

Solution is proposed here.

@nicolasstucki
Copy link
Contributor Author

But it still looks like prototypes are too tightly bound to FunctionN class symbols. Which might not actually be used, just like in this case.

@nicolasstucki nicolasstucki self-assigned this Sep 30, 2016
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Oct 3, 2016
With this change it is possible to have create types for
funtions of any arity. This ensures that the compiler will
not crash when creating FunProto when typing a method
application method applications with more than MaxFunctionArity
parameters. Note that in the language the functions are still
bound to MaxFunctionArity, but this is a first small step towards
supporting any function arity.
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Oct 3, 2016
With this change it is possible to have create types for
funtions of any arity. This ensures that the compiler will
not crash when creating FunProto when typing a method
application method applications with more than MaxFunctionArity
parameters. Note that in the language the functions are still
bound to MaxFunctionArity, but this is a first small step towards
supporting any function arity.
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Oct 3, 2016
With this change it is possible to have create types for
functions of any arity. This ensures that the compiler will
not crash when creating FunProto when typing a method
application method applications with more than MaxFunctionArity
parameters. Note that in the language the functions are still
bound to MaxFunctionArity, but this is a first small step towards
supporting any function arity.
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Oct 3, 2016
With this change it is possible to have create types for
functions of any arity. This ensures that the compiler will
not crash when creating FunProto when typing a method
application method applications with more than MaxFunctionArity
parameters. Note that in the language the functions are still
bound to MaxFunctionArity, but this is a first small step towards
supporting any function arity.
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Oct 11, 2016
odersky added a commit that referenced this issue Oct 13, 2016
Fix #1543: Ignore IgnoredProto when normalizing method application.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants