@@ -1357,7 +1357,9 @@ function expand_assignment(ctx, ex, is_const=false)
13571357 # Identifier in lhs[1] is a variable type declaration, eg
13581358 # x::T = rhs
13591359 @ast ctx ex [K " block"
1360- kind (x) === K " Placeholder" ? nothing : [K " decl" x T]
1360+ if kind (x) != = K " Placeholder"
1361+ [K " decl" x T]
1362+ end
13611363 is_const ? [K " const" [K " =" x rhs]] : [K " =" x rhs]
13621364 ]
13631365 else
@@ -2172,8 +2174,12 @@ function make_lhs_decls(ctx, stmts, declkind, declmeta, ex, type_decls=true)
21722174 if kind (name) == K " Identifier"
21732175 push! (stmts, makenode (ctx, ex, K " decl" , name, ex[2 ]))
21742176 else
2175- # Setting the global type of underscores is likely undesired.
2176- # Locals are debatable, though that isn't known here.
2177+ # TODO : Currently, this treats both globals and locals the same
2178+ # way by ignoring the LHS in `_::T = val`. For locals, we
2179+ # should probably do one of the following:
2180+ # - Throw a LoweringError if that's not too breaking
2181+ # - `convert(T, rhs)::T` and discard the result which is what
2182+ # `x::T = rhs` would do if x is never used again.
21772183 @chk kind (name) == K " Placeholder"
21782184 return
21792185 end
@@ -2316,11 +2322,14 @@ function expand_function_arg(ctx, body_stmts, arg, is_last_arg, is_kw, arg_id)
23162322 [K " =" ex name]
23172323 ])
23182324 elseif k == K " Placeholder"
2319- # The user shouldn't be able to access this name, but lowering should be
2320- # able to use it as an rvalue internally, e.g. for kw method dispatch.
2321- # Duplicate positional placeholder names should be allowed.
2322- name_str = is_kw ? " #kw$(ex. name_val) #" : " #arg$(string (arg_id)) #"
2323- name = @ast ctx ex name_str:: K"Identifier"
2325+ # Lowering should be able to use placeholder args as rvalues internally,
2326+ # e.g. for kw method dispatch. Duplicate positional placeholder names
2327+ # should be allowed.
2328+ name = if is_kw
2329+ @ast ctx ex ex=> K " Identifier"
2330+ else
2331+ new_local_binding (ctx, ex, " #arg$(string (arg_id)) #" ; kind= :argument )
2332+ end
23242333 elseif k == K " Identifier"
23252334 name = ex
23262335 else
0 commit comments