From 11b099422c024d4d73c31340150a10ee071d1bdb Mon Sep 17 00:00:00 2001 From: Morten Piibeleht Date: Wed, 9 Oct 2019 14:37:11 +1300 Subject: [PATCH] Use proper sandbox for at-setup blocks too Apply the fix from #794 to also SetupBlocks. Fix #1148. --- src/Expanders.jl | 2 +- test/examples/src/index.md | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Expanders.jl b/src/Expanders.jl index c1b83a6a48..b6b106dac3 100644 --- a/src/Expanders.jl +++ b/src/Expanders.jl @@ -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] = diff --git a/test/examples/src/index.md b/test/examples/src/index.md index 0bb619e572..f8b3f39bd6 100644 --- a/test/examples/src/index.md +++ b/test/examples/src/index.md @@ -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