Skip to content

Commit

Permalink
fix part of JuliaLang#38650, struct should be a hard scope (JuliaLa…
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Dec 3, 2020
1 parent 8ffcc0e commit 7d5c0c5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,7 @@
(global ,name) (const ,name)
(scope-block
(block
(hardscope)
(local-def ,name)
,@(map (lambda (v) `(local ,v)) params)
,@(map (lambda (n v) (make-assignment n (bounds-to-TypeVar v #t))) params bounds)
Expand Down Expand Up @@ -934,6 +935,7 @@
;; "inner" constructors
(scope-block
(block
(hardscope)
(global ,name)
,@(map (lambda (c)
(rewrite-ctor c name params field-names field-types))
Expand Down
10 changes: 10 additions & 0 deletions test/syntax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2096,6 +2096,16 @@ end
end
@test z28789 == 42

# issue #38650, `struct` should always be a hard scope
f38650() = 0
@eval begin
$(Expr(:softscope, true))
struct S38650
f38650() = 1
end
end
@test f38650() == 0

# issue #37126
@test isempty(Test.collect_test_logs() do
include_string(@__MODULE__, """
Expand Down

0 comments on commit 7d5c0c5

Please sign in to comment.