From 861527e65d3d16cee69687b579661e6ec1e10748 Mon Sep 17 00:00:00 2001 From: Gregor Kappler Date: Thu, 5 Nov 2020 00:47:18 +0100 Subject: [PATCH] Optional: _copy function for copying empty array defaults --- src/get.jl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/get.jl b/src/get.jl index f190c66..17ac43c 100644 --- a/src/get.jl +++ b/src/get.jl @@ -152,11 +152,16 @@ function Base.get(parser::Either{<:Trie}, get(state.state) end +_copy(x::Vector) = copy(x) +_copy(x::AbstractDict) = copy(x) +_copy(x::AbstractSet) = copy(x) +_copy(x) = x + function Base.get(parser::Optional, sequence, till, after, i, state) if state === None() - parser.default + _copy(parser.default) else get(parser.parser,sequence, till, after, i, state) end