Skip to content

Commit

Permalink
docs: fix scope type of a struct to hard (#56755)
Browse files Browse the repository at this point in the history
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
```
  • Loading branch information
ArnoStrouwen authored Dec 18, 2024
1 parent fc9e7c4 commit 522624c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions doc/src/manual/variables-and-scoping.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ The constructs introducing scope blocks are:
| Construct | Scope Type Introduced | Scope Types Able to Contain Construct |
|:----------|:----------------------|:--------------------------------------|
| [`module`](@ref), [`baremodule`](@ref) | global | global |
| [`struct`](@ref) | local (soft) | global |
| [`struct`](@ref) | local (hard) | global |
| [`macro`](@ref) | local (hard) | global |
| [`for`](@ref), [`while`](@ref), [`try`](@ref try) | local (soft) | global, local |
| [`function`](@ref), [`do`](@ref), [`let`](@ref), [comprehensions](@ref man-comprehensions), [generators](@ref man-generators) | local (hard) | global, local |
Expand Down Expand Up @@ -169,10 +169,10 @@ that location:
1. **Existing local:** If `x` is *already a local variable*, then the existing local `x` is
assigned;
2. **Hard scope:** If `x` is *not already a local variable* and assignment occurs inside of any
hard scope construct (i.e. within a `let` block, function or macro body, comprehension, or
hard scope construct (i.e. within a `let` block, function, struct or macro body, comprehension, or
generator), a new local named `x` is created in the scope of the assignment;
3. **Soft scope:** If `x` is *not already a local variable* and all of the scope constructs
containing the assignment are soft scopes (loops, `try`/`catch` blocks, or `struct` blocks), the
containing the assignment are soft scopes (loops, `try`/`catch` blocks), the
behavior depends on whether the global variable `x` is defined:
* if global `x` is *undefined*, a new local named `x` is created in the scope of the
assignment;
Expand Down

0 comments on commit 522624c

Please sign in to comment.