-
Notifications
You must be signed in to change notification settings - Fork 105
('a : value mod non_float) or_null
is non_float
#4158
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
base: main
Are you sure you want to change the base?
Changes from all commits
5250d68
74de086
ee53fb8
8125075
75813bf
111a99f
a39bc48
67c0337
40179b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,8 +63,8 @@ Line 1, characters 21-25: | |
^^^^ | ||
Error: This expression has type "'a or_null" | ||
but an expression was expected of type "('b : value)" | ||
The kind of 'a or_null is immediate_or_null with 'a | ||
because it is the primitive immediate_or_null type or_null. | ||
The kind of 'a or_null is value_or_null | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the change from |
||
because it is the primitive value_or_null type or_null. | ||
But the kind of 'a or_null must be a subkind of value | ||
because it's the type of an array element, | ||
chosen to have kind value. | ||
|
@@ -129,8 +129,8 @@ Line 1, characters 28-32: | |
^^^^ | ||
Error: This expression has type "'a or_null" | ||
but an expression was expected of type "('b : value)" | ||
The kind of 'a or_null is immediate_or_null with 'a | ||
because it is the primitive immediate_or_null type or_null. | ||
The kind of 'a or_null is value_or_null | ||
because it is the primitive value_or_null type or_null. | ||
But the kind of 'a or_null must be a subkind of value | ||
because it's the type of an array element, | ||
chosen to have kind value. | ||
|
@@ -260,7 +260,8 @@ let should_work_option3 = None | |
|
||
[%%expect{| | ||
val should_work_option1 : float or_null option = Some (This 3.4) | ||
val should_work_option2 : 'a or_null option = Some Null | ||
val should_work_option2 : | ||
('a : value_or_null mod non_null). 'a or_null option = Some Null | ||
val should_work_option3 : 'a option = None | ||
|}] | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,23 +5,23 @@ | |
(* CR layouts v3.5: ['a or_null] can't be re- 9E12 exported normally, | ||
because users can't define their own [Null]-like constructors. *) | ||
module Or_null = struct | ||
type ('a : value) t : immediate_or_null with 'a = 'a or_null = | ||
type ('a : value) t : value_or_null = 'a or_null = | ||
| Null | ||
| This of 'a | ||
end | ||
[%%expect{| | ||
Lines 2-4, characters 2-16: | ||
2 | ..type ('a : value) t : immediate_or_null with 'a = 'a or_null = | ||
2 | ..type ('a : value) t : value_or_null = 'a or_null = | ||
3 | | Null | ||
4 | | This of 'a | ||
Error: The kind of type "t" is immutable_data with 'a | ||
because it's a boxed variant type. | ||
But the kind of type "t" must be a subkind of immediate_or_null with 'a | ||
because of the annotation on the declaration of the type t. | ||
Error: This variant or record definition does not match that of type | ||
"'a or_null" | ||
Their internal representations differ: | ||
the original definition has a null constructor. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a terrible error message. Let's at least leave a CR to return. |
||
|}] | ||
|
||
module Or_null = struct | ||
type ('a : value) t : immediate_or_null with 'a = 'a or_null | ||
type ('a : value) t : value_or_null = 'a or_null | ||
end | ||
[%%expect{| | ||
module Or_null : sig type 'a t = 'a or_null end | ||
|
@@ -50,7 +50,7 @@ Error: Unbound constructor "Or_null.This" | |
(* [@@or_null_reexport] re-exports those constructors. *) | ||
|
||
module Or_null = struct | ||
type ('a : value) t : immediate_or_null with 'a = 'a or_null [@@or_null_reexport] | ||
type ('a : value) t : value_or_null with 'a = 'a or_null [@@or_null_reexport] | ||
end | ||
let n = Or_null.Null | ||
let t v = Or_null.This v | ||
|
@@ -70,10 +70,10 @@ Line 1, characters 24-40: | |
^^^^^^^^^^^^^^^^ | ||
Error: This expression has type "'a Or_null.t" = "'a or_null" | ||
but an expression was expected of type "('b : value)" | ||
The kind of 'a Or_null.t is immediate_or_null with 'a | ||
because it is the primitive immediate_or_null type or_null. | ||
The kind of 'a Or_null.t is value_or_null | ||
because it is the primitive value_or_null type or_null. | ||
But the kind of 'a Or_null.t must be a subkind of value | ||
because of the definition of t at line 2, characters 2-83. | ||
because of the definition of t at line 2, characters 2-79. | ||
|}] | ||
|
||
(* Type annotations are not required. *) | ||
|
@@ -91,8 +91,8 @@ Line 4, characters 24-40: | |
^^^^^^^^^^^^^^^^ | ||
Error: This expression has type "'a Or_null.t" = "'a or_null" | ||
but an expression was expected of type "('b : value)" | ||
The kind of 'a Or_null.t is immediate_or_null with 'a | ||
because it is the primitive immediate_or_null type or_null. | ||
The kind of 'a Or_null.t is value_or_null | ||
because it is the primitive value_or_null type or_null. | ||
But the kind of 'a Or_null.t must be a subkind of value | ||
because of the definition of t at line 2, characters 2-45. | ||
|}] | ||
|
@@ -105,8 +105,8 @@ type 'a t : value = 'a or_null [@@or_null_reexport] | |
Line 1, characters 0-51: | ||
1 | type 'a t : value = 'a or_null [@@or_null_reexport] | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
Error: The kind of type "'a or_null" is immediate_or_null with 'a | ||
because it is the primitive immediate_or_null type or_null. | ||
Error: The kind of type "'a or_null" is value_or_null | ||
because it is the primitive value_or_null type or_null. | ||
But the kind of type "'a or_null" must be a subkind of value | ||
because of the definition of t at line 1, characters 0-51. | ||
|}] | ||
|
@@ -118,7 +118,7 @@ Line 1, characters 0-53: | |
1 | type 'a t : float64 = 'a or_null [@@or_null_reexport] | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
Error: The layout of type "'a or_null" is value | ||
because it is the primitive immediate_or_null type or_null. | ||
because it is the primitive value_or_null type or_null. | ||
But the layout of type "'a or_null" must be a sublayout of float64 | ||
because of the definition of t at line 1, characters 0-53. | ||
|}] | ||
|
@@ -129,7 +129,8 @@ type ('a : float64) t = 'a or_null [@@or_null_reexport] | |
Line 1, characters 24-26: | ||
1 | type ('a : float64) t = 'a or_null [@@or_null_reexport] | ||
^^ | ||
Error: This type "('a : float64)" should be an instance of type "('b : value)" | ||
Error: This type "('a : float64)" should be an instance of type | ||
"('b : value_or_null mod non_null)" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is very strange. |
||
The layout of 'a is float64 | ||
because of the annotation on 'a in the declaration of the type t. | ||
But the layout of 'a must overlap with value | ||
|
@@ -146,15 +147,19 @@ let fail = Or_null.This (Or_null.This 5) | |
|
||
[%%expect{| | ||
module Or_null : | ||
sig type 'a t = 'a or_null = Null | This of 'a [@@or_null_reexport] end | ||
sig | ||
type ('a : value_or_null mod non_null) t = 'a or_null = Null | This of 'a [@@or_null_reexport] | ||
end | ||
Line 4, characters 24-40: | ||
4 | let fail = Or_null.This (Or_null.This 5) | ||
^^^^^^^^^^^^^^^^ | ||
Error: This expression has type "'a Or_null.t" = "'a or_null" | ||
but an expression was expected of type "('b : value)" | ||
The kind of 'a Or_null.t is immediate_or_null with 'a | ||
because it is the primitive immediate_or_null type or_null. | ||
But the kind of 'a Or_null.t must be a subkind of value | ||
but an expression was expected of type | ||
"('b : value_or_null mod non_null)" | ||
The kind of 'a Or_null.t is value_or_null | ||
because it is the primitive value_or_null type or_null. | ||
But the kind of 'a Or_null.t must be a subkind of | ||
value_or_null mod non_null | ||
because of the definition of t at line 2, characters 2-63. | ||
|}] | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not new in this patch, but I don't understand this comment.