@@ -1191,9 +1191,6 @@ end
11911191# * Destructuring
11921192# * Typed variable declarations
11931193function expand_assignment (ctx, ex, is_const= false )
1194- function maybe_wrap_const (ex)
1195- @ast ctx ex (is_const ? [K " const" ex] : ex)
1196- end
11971194 @chk numchildren (ex) == 2
11981195 lhs = ex[1 ]
11991196 rhs = ex[2 ]
@@ -1229,7 +1226,6 @@ function expand_assignment(ctx, ex, is_const=false)
12291226 ]
12301227 )
12311228 elseif is_identifier_like (lhs)
1232- sink_assignment (ctx, ex, lhs, expand_forms_2 (ctx, rhs))
12331229 if is_const
12341230 rr = ssavar (ctx, rhs)
12351231 @ast ctx ex [
@@ -2138,9 +2134,8 @@ function strip_decls!(ctx, stmts, declkind, declkind2, declmeta, ex)
21382134 end
21392135end
21402136
2141- # local x, (y=2), z ==> local x; local y; y = 2; local z
2142- # const x = 1 ==> const x; x = 1
2143- # global x::T = 1 ==> (block (global x) (decl x T) (x = 1))
2137+ # local x, (y=2), z ==> local x; local z; y = 2
2138+ # Note there are differences from lisp (evaluation order?)
21442139function expand_decls (ctx, ex)
21452140 declkind = kind (ex)
21462141 declmeta = get (ex, :meta , nothing )
@@ -2189,7 +2184,7 @@ end
21892184
21902185function expand_const_decl (ctx, ex)
21912186 function check_assignment (asgn)
2192- @chk (kind (asgn) == K " =" ) (ex, " expected assignment after \" const\" " )
2187+ @chk (kind (asgn) == K " =" ) (ex, " expected assignment after ` const` " )
21932188 end
21942189
21952190 k = kind (ex[1 ])
@@ -2213,8 +2208,10 @@ function expand_const_decl(ctx, ex)
22132208 elseif k == K " ="
22142209 check_assignment (ex[1 ])
22152210 expand_assignment (ctx, ex[1 ], true )
2211+ elseif k == K " local"
2212+ throw (LoweringError (ex, " unsupported `const local` declaration" ))
22162213 else
2217- throw (LoweringError (ex, " expected assignment after \" const\" " ))
2214+ throw (LoweringError (ex, " expected assignment after ` const` " ))
22182215 end
22192216end
22202217
@@ -3945,8 +3942,9 @@ function expand_struct_def(ctx, ex, docs)
39453942 # See https://github.com/JuliaLang/julia/pull/36121
39463943 @ast ctx ex [K " block"
39473944 [K " assert" " toplevel_only" :: K"Symbol" [K " inert" ex] ]
3948- [K " global" global_struct_name]
39493945 [K " scope_block" (scope_type= :hard )
3946+ # Needed for later constdecl to work, though plain global form may be removed soon.
3947+ [K " global" global_struct_name]
39503948 [K " block"
39513949 [K " local" struct_name]
39523950 [K " always_defined" struct_name]
0 commit comments