File tree Expand file tree Collapse file tree 4 files changed +64
-6
lines changed Expand file tree Collapse file tree 4 files changed +64
-6
lines changed Original file line number Diff line number Diff line change 41
41
42
42
#### :bug : Bug fix
43
43
44
+ - Fix option optimisation that resulted in incorrect JS output. https://github.com/rescript-lang/rescript/pull/7766
44
45
- Fix formatting of nested records in ` .resi ` files. https://github.com/rescript-lang/rescript/pull/7741
45
46
- Don't format and don't check formatting of dependencies. https://github.com/rescript-lang/rescript/pull/7748
46
47
- Fix ` rescript-editor-analysis semanticTokens ` returning invalid JSON in certain cases. https://github.com/rescript-lang/rescript/pull/7750
Original file line number Diff line number Diff line change @@ -26,16 +26,17 @@ type outcome = Eval_false | Eval_true | Eval_unknown
26
26
27
27
let id_is_for_sure_true_in_boolean (tbl : Lam_stats.ident_tbl ) id =
28
28
match Hash_ident. find_opt tbl id with
29
- | Some ( ImmutableBlock _)
30
- | Some (Normal_optional _)
31
- | Some ( MutableBlock _)
32
- | Some ( Constant ( Const_block _ | Const_js_true )) ->
33
- Eval_true
29
+ | Some
30
+ (Normal_optional
31
+ ( Lconst ( Const_js_false | Const_js_null | Const_js_undefined _ ))) ->
32
+ Eval_false
33
+ | Some (Constant Const_js_true) -> Eval_true
34
34
| Some (Constant (Const_int {i} )) -> if i = 0l then Eval_false else Eval_true
35
35
| Some (Constant (Const_js_false | Const_js_null | Const_js_undefined _ )) ->
36
36
Eval_false
37
37
| Some
38
- ( Constant _ | Module _ | FunctionId _ | Exception | Parameter | NA
38
+ ( Normal_optional _ | ImmutableBlock _ | MutableBlock _ | Constant _
39
+ | Module _ | FunctionId _ | Exception | Parameter | NA
39
40
| OptionalBlock (_, (Undefined | Null | Null_undefined )) )
40
41
| None ->
41
42
Eval_unknown
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
+ function boolean ( val1 , val2 ) {
6
+ let a = val1 ;
7
+ let b = val2 ;
8
+ if ( b || a ) {
9
+ return "a" ;
10
+ } else {
11
+ return "b" ;
12
+ }
13
+ }
14
+
15
+ function $$null ( val1 , val2 ) {
16
+ let a = Primitive_option . some ( val1 ) ;
17
+ let b = Primitive_option . some ( val2 ) ;
18
+ let tmp = Primitive_option . valFromOption ( b ) ;
19
+ if ( tmp !== null && tmp !== undefined ) {
20
+ return "a" ;
21
+ }
22
+ tmp === null ;
23
+ let tmp$1 = Primitive_option . valFromOption ( a ) ;
24
+ if ( tmp$1 == null ) {
25
+ return "b" ;
26
+ } else {
27
+ return "a" ;
28
+ }
29
+ }
30
+
31
+ export {
32
+ boolean ,
33
+ $$null ,
34
+ }
35
+ /* No side effect */
Original file line number Diff line number Diff line change
1
+ let boolean = (~val1 : bool , ~val2 : bool ) => {
2
+ let a = Some (val1 )
3
+ let b = Some (val2 )
4
+
5
+ switch (a , b ) {
6
+ | (_ , Some (true ))
7
+ | (Some (true ), _ ) => "a"
8
+ | _ => "b"
9
+ }
10
+ }
11
+
12
+ let null = (~val1 : Nullable .t <int >, ~val2 : Nullable .t <int >) => {
13
+ let a = Some (val1 )
14
+ let b = Some (val2 )
15
+
16
+ switch (a , b ) {
17
+ | (_ , Some (Value (_ )))
18
+ | (Some (Value (_ )), _ ) => "a"
19
+ | _ => "b"
20
+ }
21
+ }
You can’t perform that action at this time.
0 commit comments