Skip to content

Commit 85db358

Browse files
committed
Remove a special case
No longer needed since we no longer put `global` or `local` forms back into the expand_forms machine. Some error messages change slightly as a result.
1 parent 6e2a2c4 commit 85db358

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

src/desugaring.jl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4359,10 +4359,7 @@ function expand_forms_2(ctx::DesugaringContext, ex::SyntaxTree, docs=nothing)
43594359
elseif k == K"const"
43604360
expand_const_decl(ctx, ex)
43614361
elseif k == K"local" || k == K"global"
4362-
if numchildren(ex) == 1 && kind(ex[1]) == K"Identifier"
4363-
# Don't recurse when already simplified - `local x`, etc
4364-
ex
4365-
elseif k == K"global" && kind(ex[1]) == K"const"
4362+
if k == K"global" && kind(ex[1]) == K"const"
43664363
# Normalize `global const` to `const global`
43674364
expand_const_decl(ctx, @ast ctx ex [K"const" [K"global" ex[1][1]]])
43684365
else

test/scopes_ir.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ LoweringError:
276276
let
277277
local x
278278
global x
279-
# └──────┘ ── Variable `x` declared both local and global
279+
# ── Variable `x` declared both local and global
280280
end
281281

282282
########################################
@@ -288,7 +288,7 @@ end
288288
LoweringError:
289289
function f(x)
290290
local x
291-
# └─────┘ ── local variable name `x` conflicts with an argument
291+
# ── local variable name `x` conflicts with an argument
292292
end
293293

294294
########################################
@@ -300,7 +300,7 @@ end
300300
LoweringError:
301301
function f(x)
302302
global x
303-
# └──────┘ ── global variable name `x` conflicts with an argument
303+
# ── global variable name `x` conflicts with an argument
304304
end
305305

306306
########################################
@@ -313,7 +313,7 @@ end
313313
LoweringError:
314314
function f((x,))
315315
global x
316-
# └──────┘ ── Variable `x` declared both local and global
316+
# ── Variable `x` declared both local and global
317317
end
318318

319319
########################################
@@ -325,7 +325,7 @@ end
325325
LoweringError:
326326
function f(::T) where T
327327
local T
328-
# └─────┘ ── local variable name `T` conflicts with a static parameter
328+
# ── local variable name `T` conflicts with a static parameter
329329
end
330330

331331
########################################
@@ -337,7 +337,7 @@ end
337337
LoweringError:
338338
function f(::T) where T
339339
global T
340-
# └──────┘ ── global variable name `T` conflicts with a static parameter
340+
# ── global variable name `T` conflicts with a static parameter
341341
end
342342

343343
########################################
@@ -352,7 +352,7 @@ LoweringError:
352352
function f(::T) where T
353353
let
354354
local T
355-
# └─────┘ ── local variable name `T` conflicts with a static parameter
355+
# ── local variable name `T` conflicts with a static parameter
356356
end
357357
end
358358

@@ -368,7 +368,7 @@ LoweringError:
368368
function f(::T) where T
369369
let
370370
global T
371-
# └──────┘ ── global variable name `T` conflicts with a static parameter
371+
# ── global variable name `T` conflicts with a static parameter
372372
end
373373
end
374374

0 commit comments

Comments
 (0)