-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Fix #13503 by adding a "catch all" clause in pickleDef
pattern match
#13504
Conversation
Co-authored-by: Nicolas Stucki <nicolas.stucki@gmail.com>
Co-authored-by: Nicolas Stucki <nicolas.stucki@gmail.com>
|
@@ -329,7 +329,7 @@ class TreePickler(pickler: TastyPickler) { | |||
pickleName(sym.name) | |||
pickleParams | |||
tpt match { | |||
case _: Template | _: Hole => pickleTree(tpt) | |||
case _: Template | _: Literal | _: Hole => pickleTree(tpt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the problem is in the typer, not the pickler. Literal
is not a TypeTree so it shouldn't show up in tpt
, I would expect a TypeTree(ConstantType(Constant(123)))
instead /cc @nicolasstucki
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So is there anything wrong with my initial commit that just ignores Literal
? Is there really a problem in the typer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well we do need to pickle the type to be able to restore it in unpickling so I don't see how the tpt field could be ignored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, your first commit fails with
[info] Test dotty.tools.dotc.CompilationTests.pickling started
java.lang.AssertionError: assertion failed: illegal modifier tag 111 at Addr(333), end = Addr(331) while compiling tests/pos/i13503.scala
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TypeTree(ConstantType(Constant(123)))
makes more sense. We should find where this tree is created and try to change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wondering if Ycheck
should have caught this as it is a TermTree
used as a type tree.
From the discussion I get that this PR is the wrong approach, so I'm closing it. |
There's two ways I would tackle this.
|
Instead of debugging using symbol id, we can use a tree Debug tree (id=504) creation
Literal(Constant(123))
java.lang.Exception: Stack trace
at java.lang.Thread.dumpStack(Thread.java:1336)
at dotty.tools.dotc.ast.Positioned.allocateId(Positioned.scala:39)
at dotty.tools.dotc.ast.Positioned.<init>(Positioned.scala:41)
at dotty.tools.dotc.ast.Trees$Tree.<init>(Trees.scala:56)
at dotty.tools.dotc.ast.Trees$Literal.<init>(Trees.scala:545)
at dotty.tools.dotc.ast.untpd$.Literal(untpd.scala:373)
at dotty.tools.dotc.ast.tpd$.Literal(tpd.scala:57)
at dotty.tools.dotc.ast.TypedTreeInfo.constToLiteral(TreeInfo.scala:579)
at dotty.tools.dotc.ast.TypedTreeInfo.constToLiteral$(TreeInfo.scala:394)
at dotty.tools.dotc.ast.tpd$.constToLiteral(tpd.scala:22)
at dotty.tools.dotc.typer.Inliner$InlineTyper.typedSelect(Inliner.scala:1507)
at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2725)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2817)
at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:121)
at dotty.tools.dotc.typer.Inliner$InlineTyper.typedUnadapted(Inliner.scala:1635)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2883)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2887)
at dotty.tools.dotc.typer.Typer.typedType(Typer.scala:3005)
at dotty.tools.dotc.typer.Typer.typedTypeDef(Typer.scala:2278)
at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$2(Typer.scala:2745)
at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2747)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2817)
at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:121)
at dotty.tools.dotc.typer.Inliner$InlineTyper.typedUnadapted(Inliner.scala:1635)
[...] From that we can see that the problem comes from the call to constToLiteral in https://github.com/lampepfl/dotty/blob/3a6a9499f0bd1821351f052631a0a1d3842f05c1/compiler/src/dotty/tools/dotc/typer/Inliner.scala#L1507 where |
So if I understand correctly, we have the following issues:
Should all three be solved in the same PR or separate ones? |
The Ycheck one is less useful I'd say, even if we add an assert there, it won't help find the root cause of any future issue, we do have assertions on tree creations that could be changed to check that tpt.isType is true (https://github.com/lampepfl/dotty/blob/3a6a9499f0bd1821351f052631a0a1d3842f05c1/compiler/src/dotty/tools/dotc/ast/Trees.scala#L822), but it's just as easy to add that by hand whenever the compiler crashes to debug it. |
The new PR is #13578 |
No description provided.