Repository: JuliaLang/julia
File: JuliaLowering/src/desugaring.jl (Julia)

Code before:
            ]
        ]
        [K"removable"
            isnothing(bare_func_name) ? "nothing"::K"core" : bare_func_name
        ]
    ]
end

#-------------------------------------------------------------------------------
# Anon function syntax
function expand_arrow_arglist(ctx, arglist, arrowname)
    k = kind(arglist)
    if k == K"where"
        @ast ctx arglist [K"where"
            expand_arrow_arglist(ctx, arglist[1], arrowname)
            arglist[2]
        ]
    else
        # The arglist can sometimes be parsed as a block, or something else, and
        # fixing this is extremely awkward when nested inside `where`. See
        # https://github.com/JuliaLang/JuliaSyntax.jl/pull/522
        if k == K"block"
            @chk numchildren(arglist) == 2
            kw = kind(arglist[2]) === K"=" ?
                @ast(ctx, arglist[2], [K"kw" children(arglist[2])...]) :
                arglist[2]

            arglist = @ast ctx arglist [K"tuple"
                arglist[1]
                [K"parameters" kw]
            ]
        elseif k != K"tuple"
            arglist = @ast ctx arglist [K"tuple"
                arglist[1]
            ]
        end
        @ast ctx arglist [K"call"
            arrowname::K"Placeholder"
            children(arglist)...
        ]
    end
end

function expand_arrow(ctx, ex)
    @chk numchildren(ex) == 2
    expand_forms_2(ctx,
        @ast ctx ex [K"function"
            expand_arrow_arglist(ctx, ex[1], string(kind(ex)))
            ex[2]
        ]
    )

Review comment (suggestion):
```suggestion
            kw = arglist[2]
            if kind(kw) === K"="
                kw = @ast(ctx, kw, [K"kw" children(kw)...])
            end
```

just a minor suggestion, but reads more easily imo

Code after:
    push!(method_stmts,
          method_def_expr(ctx, ex, callex, method_table, main_typevar_names, arg_names,
                          arg_types, body, ret_var))

    if !isnothing(docs)
        method_stmts[end] = @ast ctx docs [K"block"
            method_metadata := method_stmts[end]
            [K"call"
                bind_docs!::K"Value"
                doc_obj
                docs[1]
                method_metadata
            ]
        ]
    end

    @ast ctx ex [K"block"
        if !isnothing(bare_func_name)
            # Need the main function type created here before running any code
            # in kw_func_method_defs
            [K"function_decl"(bare_func_name) bare_func_name]
        end
        gen_func_method_defs
        kw_func_method_defs
        [K"scope_block"(scope_type=:hard)
            [K"method_defs"
                isnothing(bare_func_name) ? "nothing"::K"core" : bare_func_name
                [K"block"
                    new_typevar_stmts...
                    if !isnothing(method_table_val)
                        [K"=" method_table method_table_val]
                    end
                    method_stmts...
                ]
            ]
        ]
        [K"removable"
            isnothing(bare_func_name) ? "nothing"::K"core" : bare_func_name
        ]
    ]
end

#-------------------------------------------------------------------------------
# Anon function syntax
function expand_arrow_args(ctx, arglist)
    k = kind(arglist)
    # The arglist can sometimes be parsed as a block, or something else, and
    # fixing this is extremely awkward when nested inside `where`. See
    # https://github.com/JuliaLang/JuliaSyntax.jl/pull/522
    if k == K"block"
        @chk numchildren(arglist) == 2