Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006451OCamlOCaml generalpublic2014-06-04 10:062014-06-05 21:38
Reporterfuruse 
Assigned Tofrisch 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version4.02.0+beta1 / +rc1 
Target VersionFixed in Version4.02.0+dev 
Summary0006451: untypeast.ml does not correctly untype ASTs.
Descriptiontools/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:

* Pwith_modsubst's lid is misused for other id's longident in typemod.ml.
* Some structure items and class fields are listed in the reversed order in the typed AST.

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.
Tagspatch
Attached Files

- Relationships

-  Notes
(0011650)
furuse (reporter)
2014-06-04 10:14

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.
(0011654)
furuse (reporter)
2014-06-04 18:26

Hi, a pull request is now available at https://github.com/ocaml/ocaml/pull/70 [^]
(0011661)
gasche (developer)
2014-06-04 22:05

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.
(0011688)
frisch (developer)
2014-06-05 21:37

Committed to 4.02 (rev 14956).

- Issue History
Date Modified Username Field Change
2014-06-04 10:06 furuse New Issue
2014-06-04 10:14 furuse Note Added: 0011650
2014-06-04 18:26 furuse Note Added: 0011654
2014-06-04 21:06 doligez Tag Attached: patch
2014-06-04 22:05 gasche Note Added: 0011661
2014-06-05 21:37 frisch Note Added: 0011688
2014-06-05 21:37 frisch Status new => resolved
2014-06-05 21:37 frisch Resolution open => fixed
2014-06-05 21:37 frisch Assigned To => frisch
2014-06-05 21:38 frisch Fixed in Version => 4.02.0+dev


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker