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

restore the error message for closing a self type #2269

merged 2 commits into from Feb 28, 2019


None yet
2 participants
Copy link

commented Feb 26, 2019

This PR fixes a bug in #2047 : when raising an error due to a missing field, I forgot to check for the dummy method of self type. As noticed by @lpw25 , this broke the error message for unifying the self type with a closed object type. Moreover, it made possible to leak this dummy method name with:

# let is_empty (x : < >) = ();;
val is_empty : <  > -> unit = <fun>
# class c = object (self) method private foo = is_empty self end;;
Line 1, characters 54-58:
1 | class c = object (self) method private foo = is_empty self end;;
Error: This expression has type < .. > but an expression was expected of type
         <  >
       The second object type has no method *dummy method*

This PR restores the correct error message

Error: This expression has type < .. > but an expression was expected of type
         <  >
       Self type cannot be unified with a closed object type

and adds a test for this case.

The second commit adds another test for a specific error that was not tested at all in the test suite. With this last commit, all explanation messages are now tested by the test suite.

@Octachron Octachron added the bug label Feb 26, 2019


gasche approved these changes Feb 26, 2019

Copy link

left a comment

This seems correct and good for 4.08. You should either add it to the "trace for unification errors" changes entry (and credit Leo), or add a new entry.

@Octachron Octachron force-pushed the Octachron:bugfix_self_closed branch from 70a9134 to 28ebbc2 Feb 27, 2019

Octachron added some commits Feb 26, 2019

testsuite: test "no intersection" error message
test the error message for non-intersecting polymorphic variant types.

@Octachron Octachron merged commit e0a11fe into ocaml:trunk Feb 28, 2019

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
continuous-integration/travis-ci/pr The Travis CI build passed

This comment has been minimized.

Copy link
Contributor Author

commented Feb 28, 2019

Cherry-picked on 4.08 as d2229a4 .

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.