Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
restore the error message for closing a self type #2269
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.