Skip to content

Commit

Permalink
Use proper sandbox for at-setup blocks too
Browse files Browse the repository at this point in the history
Apply the fix from #794 to also SetupBlocks. Fix #1148.
  • Loading branch information
mortenpi committed Oct 9, 2019
1 parent 51ad36b commit 11b0994
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Expanders.jl
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ function Selectors.runner(::Type{SetupBlocks}, x, page, doc)
# The sandboxed module -- either a new one or a cached one from this page.
name = matched[1]
sym = isempty(name) ? gensym("ex-") : Symbol("ex-", name)
mod = get!(page.globals.meta, sym, Module(sym))::Module
mod = get!(() -> get_new_sandbox(sym), page.globals.meta, sym)

# Evaluate whole @setup block at once instead of piecewise
page.mapping[x] =
Expand Down
13 changes: 13 additions & 0 deletions test/examples/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,19 @@ julia> ans
"world"
```

## Issue #1148

```@setup setup-include-test
write("issue1148.jl", "x = 1148")
r = include("issue1148.jl")
rm("issue1148.jl")
```

```@repl setup-include-test
x
@assert x == 1148
```

# Issue513

```jldoctest named
Expand Down

0 comments on commit 11b0994

Please sign in to comment.