File tree Expand file tree Collapse file tree 2 files changed +23
-25
lines changed Expand file tree Collapse file tree 2 files changed +23
-25
lines changed Original file line number Diff line number Diff line change @@ -32,27 +32,25 @@ type arg_expression =
32
32
33
33
(* we need destruct [undefined] when input is optional *)
34
34
let eval (arg : J.expression ) (dispatches : (Ast_compatible.hash_label * string) list option ) : E.t =
35
- if arg == E. undefined then E. undefined else
36
- match arg.expression_desc with
37
- | Str (_ ,s ) ->
38
- let s = match dispatches with
39
- | None -> s
40
- | Some dispatches ->
41
- (Ext_list. assoc_by_string dispatches s None ) in
42
- E. str s
43
- | _ ->
44
- match dispatches with
45
- | None ->
46
- E. poly_var_tag_access arg
47
- | Some dispatches ->
48
- E. of_block
49
- [(S. string_switch arg
50
- (Ext_list. map dispatches (fun (i ,r ) ->
51
- {J. switch_case = i ;
52
- switch_body = [S. return_stmt (E. str r)];
53
- should_break = false ; (* FIXME: if true, still print break*)
54
- comment = None ;
55
- })))]
35
+ match dispatches with
36
+ | None -> arg
37
+ | Some dispatches ->
38
+ if arg == E. undefined then E. undefined
39
+ else
40
+ match arg.expression_desc with
41
+ | Str (_ ,s ) ->
42
+ let s =
43
+ (Ext_list. assoc_by_string dispatches s None ) in
44
+ E. str s
45
+ | _ ->
46
+ E. of_block
47
+ [(S. string_switch arg
48
+ (Ext_list. map dispatches (fun (i ,r ) ->
49
+ {J. switch_case = i ;
50
+ switch_body = [S. return_stmt (E. str r)];
51
+ should_break = false ; (* FIXME: if true, still print break*)
52
+ comment = None ;
53
+ })))]
56
54
57
55
(* * invariant: optional is not allowed in this case *)
58
56
(* * arg is a polyvar *)
Original file line number Diff line number Diff line change @@ -22,15 +22,15 @@ function b(loc, b$1) {
22
22
function makeWrapper ( foo , param ) {
23
23
var tmp = { } ;
24
24
if ( foo !== undefined ) {
25
- tmp . foo = Caml_option . valFromOption ( foo ) . NAME ;
25
+ tmp . foo = Caml_option . valFromOption ( foo ) ;
26
26
}
27
27
console . log ( tmp ) ;
28
28
29
29
}
30
30
31
31
function makeWrapper2 ( foo , param ) {
32
32
console . log ( {
33
- foo : foo . NAME
33
+ foo : foo
34
34
} ) ;
35
35
36
36
}
@@ -41,7 +41,7 @@ function makeWrapper3(foo, param) {
41
41
console . log ( 2 ) ;
42
42
var tmp = { } ;
43
43
if ( foo !== undefined ) {
44
- tmp . foo = Caml_option . valFromOption ( foo ) . NAME ;
44
+ tmp . foo = Caml_option . valFromOption ( foo ) ;
45
45
}
46
46
return tmp ;
47
47
}
@@ -53,7 +53,7 @@ function makeWrapper4(foo, param) {
53
53
foo > 10 ? "b" : "a"
54
54
) ;
55
55
if ( tmp$1 !== undefined ) {
56
- tmp . foo = Caml_option . valFromOption ( tmp$1 ) . NAME ;
56
+ tmp . foo = Caml_option . valFromOption ( tmp$1 ) ;
57
57
}
58
58
return tmp ;
59
59
}
You can’t perform that action at this time.
0 commit comments