File tree Expand file tree Collapse file tree 9 files changed +75
-13
lines changed
analysis_tests/tests/src/expected Expand file tree Collapse file tree 9 files changed +75
-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 x4 = [
6
+ 1 ,
7
+ 2 ,
8
+ 3
9
+ ] ;
10
+
11
+ let x5 = ( ) => { } ;
12
+
13
+ let x10 = null ;
14
+
15
+ let x11 = Primitive_option . some ( undefined ) ;
16
+
17
+ let x20 = null ;
18
+
19
+ let x21 = new Date ( ) ;
20
+
21
+ let x22 = / t e s t / ;
22
+
23
+ let x1 = "hello" ;
24
+
25
+ let x2 = 1 ;
26
+
27
+ let x3 = "polyvar" ;
28
+
29
+ let x12 = "test" ;
30
+
31
+ export {
32
+ x1 ,
33
+ x2 ,
34
+ x3 ,
35
+ x4 ,
36
+ x5 ,
37
+ x10 ,
38
+ x11 ,
39
+ x12 ,
40
+ x20 ,
41
+ x21 ,
42
+ x22 ,
43
+ }
44
+ /* x20 Not a pure module */
Original file line number Diff line number Diff line change
1
+ let x1 = Some ("hello" )
2
+ let x2 = Some (1 )
3
+ let x3 = Some (#polyvar )
4
+ let x4 = Some ([1 , 2 , 3 ])
5
+ let x5 = Some (() => ())
6
+
7
+ let x10 = Some (Nullable .null )
8
+ let x11 = Some (Nullable .undefined )
9
+ let x12 = Some (Nullable .Value ("test" ))
10
+
11
+ let x20 = Some (Jsx .null )
12
+ let x21 = Some (Date .make ())
13
+ let x22 = Some (/ test / )
You can’t perform that action at this time.
0 commit comments