Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
untypeast.ml does not correctly untype ASTs. #6451
Original bug ID: 6451
tools/untypeast.ml exists but not quite useful since it does not untype typed AST correctly. The results are often not compilable nor too different from the original.
This is not only the incompleteness of untypeast.ml but also due to the compiler bugs. So far I found:
The compiler changes the parsed AST during the type-checking, therefore it is natural that we cannot have 100% identical untyped AST from the source code. But at least it should be more compatible and compilable.
Comment author: furuse
I have a patch to fix this issue (to some extent). With this patch I could build a bootstrapped compiler with the following paths:
source => parsing => typing => untype with untypeast.ml => typing again => code gen
This never proves the correctness of the fixed untypeast.ml, but it is better than something which produces non-compilable.
I will post the patch as a pull request at https://github.com/ocaml/ocaml later.
Comment author: @gasche
I think untypeast may become important for 4.02 -ppx users, so we should considering bugfixing this in the release branch as well. I haven't looked at the patch yet so I cannot comment on its "safeness", but those type of roundtrip tests tend to be higly effective to improve correctness, so I would be rather confident.