-
Notifications
You must be signed in to change notification settings - Fork 30
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
Internal compiler error "Impossible: LambdaStatSem.APP.argument type not arrow" when compiling MLton with MLKit #97
Comments
That is an interesting bug, which seems to be caused by a function (result of Notice also that the two files A possible fix could be to include the path in all names and not only the Notice, btw that an implementation file (.sml or .sig) is enforced to be included in an mlb-project at most once (this property is checked at toplevel for any program defined by an mlb-file). Thus, a solution could be:
Admittedly, this last restriction seems annoying, but I don't see any other solution if target code should be relocatable and if different projects should be able to make use of the result of compiling an mlb-file (e.g., precompiled basis library). |
Interesting analysis. It does seem that With respect to the last restriction, I will note that MLton's source code organization has adopted a I wonder if you could make the stamp more likely to be unique by using |
Yes - I see the problem... Unfortunately, the @MatthewFluet : Another solution that would work well with MLKit's cut-off recompilation scheme would be to allow for an mlkit-specific mlb-annotation in one of the mlb-files to specify a unique name to include instead of the hash? Technically, this last solution could be enforced (by a static check) also in the present case of the |
@melsman Yes, some kind of |
I went for the hash-solution. A hash value involving the content of the mlb-file, the name of the mlb-file, and the relative path to the source file is now used for distinguishing identifiers coming from different source files (an example hash value looks like We still need to implement a static check of wellformedness of an mlb-project enforcing that two identically named mlb-files containing identical content must be identical. It turns out that recompilation is not necessarily triggered for a source file when the hosting mlb-file changes - only when another source file on which the source file depends is changed, which is ok. This fix, however, is not sufficient to have MLKit compile MLton, which is a huge test for the MLKit implementation and has already uncovered a few other bugs!! :) At least two issues are holding back a successful compilation:
|
@melsman Thanks for investigating! In my experiments, I had encountered a couple of additional bugs beyond the
But, if the hosting mlb-file changes, won't the hash value (involving the content of the mlb-file) change? And that would require recompilation to update the identifier identities?
I wonder how well an MLKit compiled MLton would do without the GC enabled. What I'd be worried about is that there is a lot of implicit sharing between IR programs, both when translating from one IR to the next and also when optimizing via IR to IR transformations. As a whole-program compiler, the IR programs are already "big" and if the sharing forced a lot of data of the IR programs to be in the same long-lived region, then there might be memory issues.
Interesting. I guess with the heavily functorization, we are almost turning MLKit in to a whole-program compiler --- it seems that it doesn't actually generate any code until the functors are applied. It isn't strictly necessary in MLton --- just a convention for which we pay nothing when compiling MLton with MLton. But, it can be problematic for other compilers. It probably wouldn't be too bad to write a script to generate |
Yes, I also ran into this issue, which should now be fixed. It turns out that the drop-regions pass is so eager at dropping region parameters that it sometimes drops region parameters that will newer contain values, but which should be passed to a function because the function (for other instantiations) will allocate into the passed region (such cases seem to happen only with very serious use of higher-order functions)...
Hmm... I'm thinking that in practice, it will be ok that a changed hash value does not cause any recompilation by itself. The MLKit does not associate any stored information with the mlb-files, which just specify the source dependencies. Consistency is checked whenever a program is built, which may cause recompilation if some of the dependencies change. However, I speculate that there might be a scenario involving changes to mlb-files that could cause identifier clashes, but the scenario seems very very unlikely to happen in practice...
We definitely need the GC for MLton to work with the MLKit. I have an idea of how to solve the issue but it involves changing the region inference algorithm and requires associating ML type variables with parameterised regions that have region type
I'm thinking that some manual tweaking may be necessary anyway as file-based functor export rebindings will require also the functor argument signature identifier to be in scope... What would really help the MLKit would be to avoid the heavy functorisation in cases where it is not really used for multiple instantiations or for serious abstraction guarantees (I guess this is not an option ;) I believe I can solve some of the serialisation problems just by tweaking the serialisation code, but many of the environment serialisations are due to the serialisation of functor closures during static interpretation. Thanks for providing this test case - I'm sure it will improve the MLKit down the road... |
I'm closing this issue as the issue reported here has been solved. Other issues have been created related to compiling MLton with MLKit, including a meta issue (#103) for tracking general progress... |
I get an internal compiler error (
Impossible: LambdaStatSem.APP.argument type not arrow
) when compiling the current MLton sources (which recently added preliminary support for building with MLKit) with MLKit 4.6.0 (and also some other previous versions that I tried):I attach the full error message (make.mlkit-mlton.log). I didn't have much luck minimizing the
random.sml
file and its dependencies to produce a smaller example. In particular, the ICE didn't occur when I eliminated the use of theTrace.trace{,0}
functions inrandom.sml
.The text was updated successfully, but these errors were encountered: