File tree Expand file tree Collapse file tree 9 files changed +96
-13
lines changed
analysis_tests/tests/src/expected Expand file tree Collapse file tree 9 files changed +96
-13
lines changed Original file line number Diff line number Diff line change @@ -50,17 +50,14 @@ let rec type_cannot_contain_undefined (typ : Types.type_expr) (env : Env.t) =
50
50
| For_sure_yes -> true
51
51
| For_sure_no -> false
52
52
| NA -> (
53
- let untagged = ref false in
54
- match
55
- let decl = Env. find_type p env in
56
- let () =
57
- if Ast_untagged_variants. has_untagged decl.type_attributes then
58
- untagged := true
59
- in
60
- decl.type_kind
61
- with
53
+ let decl = Env. find_type p env in
54
+ match decl.type_kind with
62
55
| exception _ -> false
63
- | Type_abstract | Type_open -> false
56
+ | Type_abstract ->
57
+ List. exists
58
+ (fun ({txt} , _ ) -> txt = " notUndefined" )
59
+ decl.type_attributes
60
+ | Type_open -> false
64
61
| Type_record _ -> true
65
62
| Type_variant
66
63
( [
@@ -74,10 +71,13 @@ let rec type_cannot_contain_undefined (typ : Types.type_expr) (env : Env.t) =
74
71
| [{cd_id = {name = " ()" }; cd_args = Cstr_tuple [] }] ) ->
75
72
false (* conservative *)
76
73
| Type_variant cdecls ->
74
+ let untagged =
75
+ Ast_untagged_variants. has_untagged decl.type_attributes
76
+ in
77
77
Ext_list. for_all cdecls (fun cd ->
78
78
if Ast_untagged_variants. has_undefined_literal cd.cd_attributes then
79
79
false
80
- else if ! untagged then
80
+ else if untagged then
81
81
match cd.cd_args with
82
82
| Cstr_tuple [t] ->
83
83
Ast_untagged_variants. type_is_builtin_object t
Original file line number Diff line number Diff line change 24
24
25
25
// Define this as a private empty record so that the compiler does not
26
26
// unnecessarily add `Primitive_option.some` calls for optional props.
27
- type element = private {}
27
+ @notUndefined
28
+ type element
28
29
29
30
@val external null : element = "null"
30
31
Original file line number Diff line number Diff line change
1
+ @notUndefined
1
2
type t
2
3
3
4
type msSinceEpoch = float
Original file line number Diff line number Diff line change 5
5
/**
6
6
A type representing a JavaScript date.
7
7
*/
8
+ @notUndefined
8
9
type t
9
10
10
11
/**
Original file line number Diff line number Diff line change
1
+ @notUndefined
1
2
type t
2
3
3
4
module Result = {
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ See [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference
7
7
/**
8
8
Type representing an instantiated `RegExp`.
9
9
*/
10
+ @notUndefined
10
11
type t
11
12
12
13
module Result : {
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as Primitive_option from "rescript/lib/es6/Primitive_option.js" ;
4
+
5
+ let x6 = {
6
+ x : 42
7
+ } ;
8
+
9
+ let x7 = [
10
+ 1 ,
11
+ 2 ,
12
+ 3
13
+ ] ;
14
+
15
+ let x8 = ( ) => { } ;
16
+
17
+ let x10 = null ;
18
+
19
+ let x11 = Primitive_option . some ( undefined ) ;
20
+
21
+ let x20 = null ;
22
+
23
+ let x21 = new Date ( ) ;
24
+
25
+ let x22 = / t e s t / ;
26
+
27
+ let x1 = "hello" ;
28
+
29
+ let x2 = 1 ;
30
+
31
+ let x3 = {
32
+ TAG : "Ok" ,
33
+ _0 : "hi"
34
+ } ;
35
+
36
+ let x4 = "polyvar" ;
37
+
38
+ let x5 = {
39
+ x : 42
40
+ } ;
41
+
42
+ let x12 = "test" ;
43
+
44
+ export {
45
+ x1 ,
46
+ x2 ,
47
+ x3 ,
48
+ x4 ,
49
+ x5 ,
50
+ x6 ,
51
+ x7 ,
52
+ x8 ,
53
+ x10 ,
54
+ x11 ,
55
+ x12 ,
56
+ x20 ,
57
+ x21 ,
58
+ x22 ,
59
+ }
60
+ /* x20 Not a pure module */
Original file line number Diff line number Diff line change
1
+ type test = {x : int }
2
+
3
+ let x1 = Some ("hello" )
4
+ let x2 = Some (1 )
5
+ let x3 = Some (Ok ("hi" ))
6
+ let x4 = Some (#polyvar )
7
+ let x5 = Some ({x : 42 })
8
+ let x6 = Some ({"x" : 42 })
9
+ let x7 = Some ([1 , 2 , 3 ])
10
+ let x8 = Some (() => ())
11
+
12
+ let x10 = Some (Nullable .null )
13
+ let x11 = Some (Nullable .undefined )
14
+ let x12 = Some (Nullable .Value ("test" ))
15
+
16
+ let x20 = Some (Jsx .null )
17
+ let x21 = Some (Date .make ())
18
+ let x22 = Some (/ test / )
You can’t perform that action at this time.
0 commit comments