Skip to content

Reimplement Typecore.final_subexpression on Typedtree, not Parsetree#8775

Merged
nojb merged 3 commits intoocaml:trunkfrom
alainfrisch:final_subexpr_on_typedtree
Jul 2, 2019
Merged

Reimplement Typecore.final_subexpression on Typedtree, not Parsetree#8775
nojb merged 3 commits intoocaml:trunkfrom
alainfrisch:final_subexpr_on_typedtree

Conversation

@alainfrisch
Copy link
Copy Markdown
Contributor

This function is used to refine the location of warning 21 "this statement never returns (or has an unsound type.", e.g. to avoid pointing to an expression of the form let ... = .... in e (but point to e instead). In this PR:

  • The traversal is done in the resulting Typedtree, not the original Parsetree. This removes one ad hoc traversal of the Parsetree (see New implementation of Env.make_copy_of_types #8774 for some contexts of why this could be useful).
  • The traversal is done only when the warning needs to be raised. This removes a quadratic behavior (ok, a cheap one) on long sequences.
  • Local opens/modules bindings/exception definitions are traversed as well.

Copy link
Copy Markdown
Contributor

@nojb nojb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a clear win to me, and with a test. LGTM!

@alainfrisch
Copy link
Copy Markdown
Contributor Author

Note: a similar operation to refine a warning's location is done in Typecore.check_partial_application, already at the Typedtree level (but not traversing exactly the same syntactic forms).

@nojb nojb merged commit fa33a18 into ocaml:trunk Jul 2, 2019
@nojb
Copy link
Copy Markdown
Contributor

nojb commented Jul 2, 2019

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants