Skip to content

Commit

Permalink
Add some tests related to instance variables
Browse files Browse the repository at this point in the history
  • Loading branch information
lpw25 committed Aug 15, 2019
1 parent 4af0a00 commit 27f621d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
11 changes: 0 additions & 11 deletions testsuite/tests/typing-misc/typecore_errors.ml
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,6 @@ Error: This expression has type 'a * 'b
|}]


(** Masked instance variable *)
let c = object val x= 0 val y = x end
[%%expect{|
Line 1, characters 32-33:
1 | let c = object val x= 0 val y = x end
^
Error: The instance variable x
cannot be accessed from the definition of another instance variable
|}]


(** No value clause *)

let f x = match x with exception Not_found -> ();;
Expand Down
31 changes: 31 additions & 0 deletions testsuite/tests/typing-objects/Tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -916,3 +916,34 @@ Line 2, characters 8-52:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: This kind of recursive class expression is not allowed
|}];;

class a = object val x = 3 val y = x + 2 end;;
[%%expect{|
Line 1, characters 35-36:
1 | class a = object val x = 3 val y = x + 2 end;;
^
Error: The instance variable x
cannot be accessed from the definition of another instance variable
|}];;

class a = object (self) val x = self#m method m = 3 end;;
[%%expect{|
Line 1, characters 32-36:
1 | class a = object (self) val x = self#m method m = 3 end;;
^^^^
Error: The instance variable self
cannot be accessed from the definition of another instance variable
|}];;

class a = object method m = 3 end
class b = object inherit a as super val x = super#m end;;
[%%expect{|
class a : object method m : int end
Line 2, characters 44-49:
2 | class b = object inherit a as super val x = super#m end;;
^^^^^
Error: The instance variable super
cannot be accessed from the definition of another instance variable
|}];;


0 comments on commit 27f621d

Please sign in to comment.