You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to implement an parametric AST where the Term enum can be parameterized with a type T used to recursively build well-typed terms (so a Term[Type] can only contain other Term[Type]) and a "Tag" K.
On changing the program to not have K (note the mistake where the Fun node still has an unbound type variable K), I get a different error:
In the program above, I expected the compiler to infer the type for tExp to be Term[Type, Kind]. Instead, it infinite loops. If this is expected behavior, can someone explain what's happening?
The text was updated successfully, but these errors were encountered:
The same effects happen if the enum is expanded to explicit classes and objects.
The root cause is that the error messages get too big since there is an implicit unrolling of the Term recursion. We do have a break in that we stop with ... after 100 recursions. This explains the behavior in the second case, where the recursion is linear. But in the first case, we have a fan out of 2 in the type, so a recursion depth of 100 gives an output of size 2^100.
This is an inherent problem of the functional approach to formatting. If we printed imperatively, the output would just go on and on until the user presses ^C. But since we format the text as a purely functional value, we see nothing before we run out of memory.
odersky
added a commit
to dotty-staging/dotty
that referenced
this issue
Mar 11, 2020
reproduction steps
Running the following program crashes the compiler with
java.lang.OutOfMemoryError
.problem
I was trying to implement an parametric AST where the
Term
enum can be parameterized with a typeT
used to recursively build well-typed terms (so aTerm[Type]
can only contain otherTerm[Type]
) and a "Tag"K
.On changing the program to not have
K
(note the mistake where theFun
node still has an unbound type variableK
), I get a different error:expectation
In the program above, I expected the compiler to infer the type for
tExp
to beTerm[Type, Kind]
. Instead, it infinite loops. If this is expected behavior, can someone explain what's happening?The text was updated successfully, but these errors were encountered: