Skip to content

Commit 5d0d0e9

Browse files
ArnoStrouwenKristofferC
authored andcommitted
docs: fix scope type of a struct to hard (#56755)
Is struct not a hard scope? ```jl julia> b = 1 struct Tester tester Tester(tester) = new(tester) b = 2 Tester() = new(b) end b 1 ``` (cherry picked from commit 522624c)
1 parent 973d116 commit 5d0d0e9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

doc/src/manual/variables-and-scoping.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ The constructs introducing scope blocks are:
2323
| Construct | Scope type | Allowed within |
2424
|:----------|:-----------|:---------------|
2525
| [`module`](@ref), [`baremodule`](@ref) | global | global |
26-
| [`struct`](@ref) | local (soft) | global |
26+
| [`struct`](@ref) | local (hard) | global |
2727
| [`for`](@ref), [`while`](@ref), [`try`](@ref try) | local (soft) | global, local |
2828
| [`macro`](@ref) | local (hard) | global |
2929
| functions, [`do`](@ref) blocks, [`let`](@ref) blocks, comprehensions, generators | local (hard) | global, local |
@@ -128,10 +128,10 @@ that location:
128128
1. **Existing local:** If `x` is *already a local variable*, then the existing local `x` is
129129
assigned;
130130
2. **Hard scope:** If `x` is *not already a local variable* and assignment occurs inside of any
131-
hard scope construct (i.e. within a `let` block, function or macro body, comprehension, or
131+
hard scope construct (i.e. within a `let` block, function, struct or macro body, comprehension, or
132132
generator), a new local named `x` is created in the scope of the assignment;
133133
3. **Soft scope:** If `x` is *not already a local variable* and all of the scope constructs
134-
containing the assignment are soft scopes (loops, `try`/`catch` blocks, or `struct` blocks), the
134+
containing the assignment are soft scopes (loops, `try`/`catch` blocks), the
135135
behavior depends on whether the global variable `x` is defined:
136136
* if global `x` is *undefined*, a new local named `x` is created in the scope of the
137137
assignment;

0 commit comments

Comments
 (0)