Add some tests related to instance variables
parent
4af0a0026d
commit
27f621da75
|
@ -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 -> ();;
|
||||
|
|
|
@ -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
|
||||
|}];;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue