Skip to content

Commit 6be3aec

Browse files
authored
Mark result of evaluation of the RHS as local (#3)
* Mark evaluation result as `local` * Bump version * Add test
1 parent 2d5e963 commit 6be3aec

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SimpleUnPack"
22
uuid = "ce78b400-467f-4804-87d8-8f486da07d0a"
33
authors = ["David Widmann"]
4-
version = "1.0.0"
4+
version = "1.0.1"
55

66
[compat]
77
julia = "1"

src/SimpleUnPack.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ function destructuring_expr(fsym::Symbol, names, rhs)
9393
end
9494
return Base.remove_linenums!(
9595
quote
96-
$(esc(object)) = $(esc(rhs)) # In case the RHS is an expression
96+
local $(esc(object)) = $(esc(rhs)) # In case the RHS is an expression
9797
$block
9898
$(esc(object)) # Return evaluation of the RHS
9999
end,

test/runtests.jl

+10
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ macro test_macro_throws(err_expr, expr)
4848
end
4949
end
5050

51+
# Module for testing behaviour in global scope (issue #3)
52+
baremodule A
53+
using SimpleUnPack
54+
@unpack a = (a=1.5, b=3)
55+
end
56+
5157
@testset "SimpleUnPack.jl" begin
5258
@testset "Variable as RHS" begin
5359
d = (x=42, y=1.0, z="z1")
@@ -161,4 +167,8 @@ end
161167
@test_macro_throws ArgumentError @unpack_fields x, y, (; x=42, y=1.0)
162168
@test_macro_throws ArgumentError @unpack_fields x, 1 = (; x=42, y=1.0)
163169
end
170+
171+
@testset "global scope (issue #3)" begin
172+
@test names(A; all=true) == [:A, :a]
173+
end
164174
end

0 commit comments

Comments
 (0)