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) =
5050 | For_sure_yes -> true
5151 | For_sure_no -> false
5252 | 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
6255 | 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
6461 | Type_record _ -> true
6562 | Type_variant
6663 ( [
@@ -74,10 +71,13 @@ let rec type_cannot_contain_undefined (typ : Types.type_expr) (env : Env.t) =
7471 | [{cd_id = {name = " ()" }; cd_args = Cstr_tuple [] }] ) ->
7572 false (* conservative *)
7673 | Type_variant cdecls ->
74+ let untagged =
75+ Ast_untagged_variants. has_untagged decl.type_attributes
76+ in
7777 Ext_list. for_all cdecls (fun cd ->
7878 if Ast_untagged_variants. has_undefined_literal cd.cd_attributes then
7979 false
80- else if ! untagged then
80+ else if untagged then
8181 match cd.cd_args with
8282 | Cstr_tuple [t] ->
8383 Ast_untagged_variants. type_is_builtin_object t
Original file line number Diff line number Diff line change 2424
2525// Define this as a private empty record so that the compiler does not
2626// unnecessarily add `Primitive_option.some` calls for optional props.
27- type element = private {}
27+ @notUndefined
28+ type element
2829
2930@val external null : element = "null"
3031
Original file line number Diff line number Diff line change 1+ @notUndefined
12type t
23
34type msSinceEpoch = float
Original file line number Diff line number Diff line change 55/**
66A type representing a JavaScript date.
77*/
8+ @notUndefined
89type t
910
1011/**
Original file line number Diff line number Diff line change 1+ @notUndefined
12type t
23
34module 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
77/**
88Type representing an instantiated `RegExp`.
99*/
10+ @notUndefined
1011type t
1112
1213module 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