Skip to content
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

untypeast.ml does not correctly untype ASTs. #6451

Closed
vicuna opened this issue Jun 4, 2014 · 4 comments

Comments

Projects
None yet
2 participants
@vicuna
Copy link

commented Jun 4, 2014

Original bug ID: 6451
Reporter: furuse
Assigned to: @alainfrisch
Status: closed (set by @xavierleroy on 2015-12-11T18:28:00Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.02.0+beta1 / +rc1
Fixed in version: 4.02.0+dev
Category: ~DO NOT USE (was: OCaml general)
Tags: patch
Monitored by: @gasche

Bug description

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:

  • 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.

@vicuna

This comment has been minimized.

Copy link
Author

commented Jun 4, 2014

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.

@vicuna

This comment has been minimized.

Copy link
Author

commented Jun 4, 2014

Comment author: furuse

Hi, a pull request is now available at #70

@vicuna

This comment has been minimized.

Copy link
Author

commented Jun 4, 2014

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.

@vicuna

This comment has been minimized.

Copy link
Author

commented Jun 5, 2014

Comment author: @alainfrisch

Committed to 4.02 (rev 14956).

@vicuna vicuna closed this Dec 11, 2015

@vicuna vicuna added the bug label Mar 20, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.