@@ -414,7 +414,7 @@ function expand_tuple_destruct(ctx, ex)
414414 end
415415
416416 if kind (rhs) == K " tuple"
417- num_splat = sum (kind (rh) == K " ..." for rh in children (rhs))
417+ num_splat = sum (kind (rh) == K " ..." for rh in children (rhs); init = 0 )
418418 if num_splat == 0 && (numchildren (lhs) - num_slurp) > numchildren (rhs)
419419 throw (LoweringError (ex, " More variables on left hand side than right hand in tuple assignment" ))
420420 end
@@ -1402,7 +1402,7 @@ function expand_condition(ctx, ex)
14021402 if isblock
14031403 # Special handling so that the rules for `&&` and `||` can be applied
14041404 # to the last statement of a block
1405- @ast ctx ex [K " block" ex[1 : end - 1 ]. .. test]
1405+ @ast ctx ex [K " block" map (e -> expand_forms_2 (ctx,e), ex[1 : end - 1 ]) ... test]
14061406 else
14071407 test
14081408 end
@@ -2112,7 +2112,7 @@ end
21122112
21132113# Separate decls and assignments (which require re-expansion)
21142114# local x, (y=2), z ==> local x; local z; y = 2
2115- function expand_decls (ctx, ex, is_const = false )
2115+ function expand_decls (ctx, ex)
21162116 declkind = kind (ex)
21172117 @assert declkind in KSet " local global"
21182118 declmeta = get (ex, :meta , nothing )
@@ -2124,7 +2124,7 @@ function expand_decls(ctx, ex, is_const=false)
21242124 @chk numchildren (binding) == 2
21252125 lhs = strip_decls! (ctx, stmts, declkind, declmeta, binding[1 ])
21262126 push! (stmts, expand_assignment (ctx, @ast ctx binding [kb lhs binding[2 ]]))
2127- elseif is_sym_decl (binding) && ! is_const
2127+ elseif is_sym_decl (binding)
21282128 strip_decls! (ctx, stmts, declkind, declmeta, binding)
21292129 else
21302130 throw (LoweringError (ex, " invalid syntax in variable declaration" ))
@@ -3085,7 +3085,7 @@ function expand_arrow_arglist(ctx, arglist, arrowname)
30853085 if k == K " where"
30863086 @ast ctx arglist [K " where"
30873087 expand_arrow_arglist (ctx, arglist[1 ], arrowname)
3088- argslist [2 ]
3088+ arglist [2 ]
30893089 ]
30903090 else
30913091 # The arglist can sometimes be parsed as a block, or something else, and
@@ -3094,13 +3094,12 @@ function expand_arrow_arglist(ctx, arglist, arrowname)
30943094 if k == K " block"
30953095 @chk numchildren (arglist) == 2
30963096 arglist = @ast ctx arglist [K " tuple"
3097- ex [1 ]
3098- [K " parameters" ex [2 ]]
3097+ arglist [1 ]
3098+ [K " parameters" arglist [2 ]]
30993099 ]
31003100 elseif k != K " tuple"
3101- # `x::Int -> body`
31023101 arglist = @ast ctx arglist [K " tuple"
3103- ex [1 ]
3102+ arglist [1 ]
31043103 ]
31053104 end
31063105 @ast ctx arglist [K " call"
@@ -3665,7 +3664,7 @@ function _rewrite_ctor_new_calls(ctx, ex, struct_name, global_struct_name, ctor_
36653664 full_struct_type = if kind (ex[1 ]) == K " curly"
36663665 # new{A,B}(...)
36673666 new_type_params = ex[1 ][2 : end ]
3668- n_type_splat = sum (kind (t) == K " ..." for t in new_type_params)
3667+ n_type_splat = sum (kind (t) == K " ..." for t in new_type_params; init = 0 )
36693668 n_type_nonsplat = length (new_type_params) - n_type_splat
36703669 if n_type_splat == 0 && n_type_nonsplat < length (struct_typevars)
36713670 throw (LoweringError (ex[1 ], " too few type parameters specified in `new{...}`" ))
@@ -3685,7 +3684,7 @@ function _rewrite_ctor_new_calls(ctx, ex, struct_name, global_struct_name, ctor_
36853684 end
36863685 end
36873686 new_args = ex[2 : end ]
3688- n_splat = sum (kind (t) == K " ..." for t in new_args)
3687+ n_splat = sum (kind (t) == K " ..." for t in new_args; init = 0 )
36893688 n_nonsplat = length (new_args) - n_splat
36903689 n_fields = length (field_types)
36913690 function throw_n_fields_error (desc)
0 commit comments