Skip to content

test suite: examples for error paths in typecore.ml#1882

Merged
gasche merged 2 commits intoocaml:trunkfrom
Octachron:typecore_error_paths_examples
Jul 4, 2018
Merged

test suite: examples for error paths in typecore.ml#1882
gasche merged 2 commits intoocaml:trunkfrom
Octachron:typecore_error_paths_examples

Conversation

@Octachron
Copy link
Copy Markdown
Member

This PR is the negative counterpart to #1868, #1872 and #1881: it adds a small example for every error path of the form raise(Error(…)) in typecore.ml that was not covered anywhere else in the test suite.
Most of the examples tested in this PR are trivial, but they helped me to identify the issues raised in the above PRs.

There is one small exception, due to an error that is only reachable with a ppx that would create an empty polymorphic variant type abbreviation:

type t = [%empty_polymorphic_variant]
let f = function #t -> ()

I am currently planning to add support for ppx in ocamltest to also cover this error.

@Octachron Octachron force-pushed the typecore_error_paths_examples branch from 16f724e to e6d1566 Compare July 4, 2018 15:25
Copy link
Copy Markdown
Member

@gasche gasche left a comment

Choose a reason for hiding this comment

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

Very nice work! Feel free to merge after possibly considering my minor comment on the non-character interval pattern.

let x = function 'a'..10 -> ()
[%%expect {|
Line _, characters 17-24:
let x = function 'a'..10 -> ()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would prefer the use of a type-correct integer pattern, eg 1 .. 10, instead of a weird char-int pattern, so that the test would remain robust to a hypothetical reordering of type inference and type-of-intervals checking.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good point, fixed with a float range pattern.

Line _, characters 6-13:
let f (A x|C) = 0
^^^^^^^
Error: Variable x must occur on both sides of this | pattern
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not your fault but the error message is weird, I would expect or-pattern instead of using a symbol in the middle of a sentence.

@gasche gasche merged commit 29fd57c into ocaml:trunk Jul 4, 2018
EmileTrotignon pushed a commit to EmileTrotignon/ocaml that referenced this pull request Jan 12, 2024
…1882)

* add a section on how to generate odoc documentation pages with dune
* minor formatting fixes

---------

Co-authored-by: Christine Rose <christinerose@users.noreply.github.com>
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.

2 participants