@@ -17,7 +17,8 @@ is_call(ex::Expr) =
17
17
ex. head == :call && ! startswith (String (ex. args[1 ]), " ." )
18
18
19
19
is_dotcall (ex:: Expr ) =
20
- ex. head == :. || (ex. head == :call && startswith (String (ex. args[1 ]), " ." ))
20
+ (ex. head == :. && ex. args[2 ]. head === :tuple ) ||
21
+ (ex. head == :call && startswith (String (ex. args[1 ]), " ." ))
21
22
# e.g., `f.(x, y, z)` or `x .+ y .+ z`
22
23
23
24
lazy_expr (x) = x
40
41
bc_expr_impl (x) = x
41
42
function bc_expr_impl (ex:: Expr )
42
43
# walk down chain of dot calls
43
- if is_dotcall (ex)
44
- return Expr (ex. head,
45
- lazy_expr (ex. args[1 ]), # function name (`f`, `.+`, etc.)
46
- bc_expr_impl .(ex. args[2 : end ])... ) # arguments
44
+ if ex. head == :. && ex. args[2 ]. head === :tuple
45
+ @assert length (ex. args) == 2 # argument is always expressed as a tuple
46
+ f = ex. args[1 ] # function name
47
+ args = ex. args[2 ]. args
48
+ return Expr (ex. head, lazy_expr (f), Expr (:tuple , bc_expr_impl .(args)... ))
49
+ elseif ex. head == :call && startswith (String (ex. args[1 ]), " ." )
50
+ f = ex. args[1 ] # function name (e.g., `.+`)
51
+ args = ex. args[2 : end ]
52
+ return Expr (ex. head, lazy_expr (f), bc_expr_impl .(args)... )
47
53
else
54
+ @assert ! is_dotcall (ex)
48
55
return lazy_expr (ex)
49
56
end
50
57
end
0 commit comments