"Type NamedTuple has no field" error

@model function f()
    s ~ Bernoulli(.5)
    if s == 1
        v~Normal(0,1)
    else
        w ~ Normal(1,2)
    end
end;

model = f();

chain=sample(model,PG(20),100)        

gives the error

CTaskException:
type NamedTuple has no field v
Stacktrace:
 [1] getmetadata(::DynamicPPL.VarInfo{NamedTuple{(:s, :w),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:s,Tuple{}},Int64},Array{Bernoulli{Float64},1},Array{DynamicPPL.VarName{:s,Tuple{}},1},BitArray{1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:w,Tuple{}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:w,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64}, ::DynamicPPL.VarName{:v,Tuple{}}) at C:\Users\Manoj\.julia\packages\DynamicPPL\h0R38\src\varinfo.jl:234
 [2] push!(::DynamicPPL.VarInfo{NamedTuple{(:s, :w),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:s,Tuple{}},Int64},Array{Bernoulli{Float64},1},Array{DynamicPPL.VarName{:s,Tuple{}},1},BitArray{1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:w,Tuple{}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:w,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64}, ::DynamicPPL.VarName{:v,Tuple{}}, ::Float64, ::Normal{Float64}, ::Set{DynamicPPL.Selector}) at C:\Users\Manoj\.julia\packages\DynamicPPL\h0R38\src\varinfo.jl:1030
 [3] push!(::DynamicPPL.VarInfo{NamedTuple{(:s, :w),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:s,Tuple{}},Int64},Array{Bernoulli{Float64},1},Array{DynamicPPL.VarName{:s,Tuple{}},1},BitArray{1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:w,Tuple{}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:w,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64}, ::DynamicPPL.VarName{:v,Tuple{}}, ::Float64, ::Normal{Float64}, ::DynamicPPL.Selector) at C:\Users\Manoj\.julia\packages\DynamicPPL\h0R38\src\varinfo.jl:1012
 [4] push!(::DynamicPPL.VarInfo{NamedTuple{(:s, :w),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:s,Tuple{}},Int64},Array{Bernoulli{Float64},1},Array{DynamicPPL.VarName{:s,Tuple{}},1},BitArray{1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:w,Tuple{}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:w,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64}, ::DynamicPPL.VarName{:v,Tuple{}}, ::Float64, ::Normal{Float64}, ::DynamicPPL.Sampler{PG{(),Turing.Core.ResampleWithESSThreshold{typeof(Turing.Inference.resample_systematic),Float64}},Turing.Inference.PGState{DynamicPPL.VarInfo{NamedTuple{(:s, :w),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:s,Tuple{}},Int64},Array{Bernoulli{Float64},1},Array{DynamicPPL.VarName{:s,Tuple{}},1},BitArray{1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:w,Tuple{}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:w,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64},Float64}}) at C:\Users\Manoj\.julia\packages\DynamicPPL\h0R38\src\varinfo.jl:999
 [5] assume(::DynamicPPL.Sampler{PG{(),Turing.Core.ResampleWithESSThreshold{typeof(Turing.Inference.resample_systematic),Float64}},Turing.Inference.PGState{DynamicPPL.VarInfo{NamedTuple{(:s, :w),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:s,Tuple{}},Int64},Array{Bernoulli{Float64},1},Array{DynamicPPL.VarName{:s,Tuple{}},1},BitArray{1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:w,Tuple{}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:w,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64},Float64}}, ::Normal{Float64}, ::DynamicPPL.VarName{:v,Tuple{}}, ::DynamicPPL.VarInfo{NamedTuple{(:s, :w),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:s,Tuple{}},Int64},Array{Bernoulli{Float64},1},Array{DynamicPPL.VarName{:s,Tuple{}},1},BitArray{1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:w,Tuple{}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:w,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64}) at C:\Users\Manoj\.julia\packages\Turing\d4vqQ\src\inference\AdvancedSMC.jl:320
 [6] _tilde at C:\Users\Manoj\.julia\packages\DynamicPPL\h0R38\src\context_implementations.jl:59 [inlined]
 [7] tilde at C:\Users\Manoj\.julia\packages\DynamicPPL\h0R38\src\context_implementations.jl:23 [inlined]
 [8] tilde_assume at C:\Users\Manoj\.julia\packages\DynamicPPL\h0R38\src\context_implementations.jl:52 [inlined]
 [9] macro expansion at .\In[107]:4 [inlined]
 [10] ##evaluator#1034(::DynamicPPL.Model{var"###evaluator#1034",(),Tuple{},(),DynamicPPL.ModelGen{var"###generator#1035",(),(),Tuple{}}}, ::DynamicPPL.VarInfo{NamedTuple{(:s, :w),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:s,Tuple{}},Int64},Array{Bernoulli{Float64},1},Array{DynamicPPL.VarName{:s,Tuple{}},1},BitArray{1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:w,Tuple{}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:w,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64}, ::DynamicPPL.Sampler{PG{(),Turing.Core.ResampleWithESSThreshold{typeof(Turing.Inference.resample_systematic),Float64}},Turing.Inference.PGState{DynamicPPL.VarInfo{NamedTuple{(:s, :w),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:s,Tuple{}},Int64},Array{Bernoulli{Float64},1},Array{DynamicPPL.VarName{:s,Tuple{}},1},BitArray{1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:w,Tuple{}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:w,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64},Float64}}, ::DynamicPPL.DefaultContext) at C:\Users\Manoj\.julia\packages\DynamicPPL\h0R38\src\compiler.jl:355
 [11] evaluate_singlethreaded at C:\Users\Manoj\.julia\packages\DynamicPPL\h0R38\src\model.jl:147 [inlined]
 [12] Model at C:\Users\Manoj\.julia\packages\DynamicPPL\h0R38\src\model.jl:136 [inlined]
 [13] Model at C:\Users\Manoj\.julia\packages\DynamicPPL\h0R38\src\model.jl:135 [inlined]
 [14] #3 at C:\Users\Manoj\.julia\packages\Turing\d4vqQ\src\core\container.jl:43 [inlined]
 [15] (::Libtask.var"#1#2"{Turing.Core.var"#3#4"{DynamicPPL.Model{var"###evaluator#1034",(),Tuple{},(),DynamicPPL.ModelGen{var"###generator#1035",(),(),Tuple{}}},DynamicPPL.Sampler{PG{(),Turing.Core.ResampleWithESSThreshold{typeof(Turing.Inference.resample_systematic),Float64}},Turing.Inference.PGState{DynamicPPL.VarInfo{NamedTuple{(:s, :w),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:s,Tuple{}},Int64},Array{Bernoulli{Float64},1},Array{DynamicPPL.VarName{:s,Tuple{}},1},BitArray{1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:w,Tuple{}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:w,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64},Float64}},DynamicPPL.VarInfo{NamedTuple{(:s, :w),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:s,Tuple{}},Int64},Array{Bernoulli{Float64},1},Array{DynamicPPL.VarName{:s,Tuple{}},1},BitArray{1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:w,Tuple{}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:w,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64}}})() at C:\Users\Manoj\.julia\packages\Libtask\Q1ugc\src\ctask.jl:65

Stacktrace:
 [1] consume(::CTask) at C:\Users\Manoj\.julia\packages\Libtask\Q1ugc\src\ctask.jl:214
 [2] consume at C:\Users\Manoj\.julia\packages\Turing\d4vqQ\src\core\container.jl:57 [inlined]
 [3] reweight!(::Turing.Core.ParticleContainer{Turing.Core.Trace{DynamicPPL.Sampler{PG{(),Turing.Core.ResampleWithESSThreshold{typeof(Turing.Inference.resample_systematic),Float64}},Turing.Inference.PGState{DynamicPPL.VarInfo{NamedTuple{(:s, :w),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:s,Tuple{}},Int64},Array{Bernoulli{Float64},1},Array{DynamicPPL.VarName{:s,Tuple{}},1},BitArray{1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:w,Tuple{}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:w,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64},Float64}},DynamicPPL.VarInfo{NamedTuple{(:s, :w),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:s,Tuple{}},Int64},Array{Bernoulli{Float64},1},Array{DynamicPPL.VarName{:s,Tuple{}},1},BitArray{1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:w,Tuple{}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:w,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64},DynamicPPL.Model{var"###evaluator#1034",(),Tuple{},(),DynamicPPL.ModelGen{var"###generator#1035",(),(),Tuple{}}}}}) at C:\Users\Manoj\.julia\packages\Turing\d4vqQ\src\core\container.jl:252
 [4] sweep!(::Turing.Core.ParticleContainer{Turing.Core.Trace{DynamicPPL.Sampler{PG{(),Turing.Core.ResampleWithESSThreshold{typeof(Turing.Inference.resample_systematic),Float64}},Turing.Inference.PGState{DynamicPPL.VarInfo{NamedTuple{(:s, :w),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:s,Tuple{}},Int64},Array{Bernoulli{Float64},1},Array{DynamicPPL.VarName{:s,Tuple{}},1},BitArray{1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:w,Tuple{}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:w,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64},Float64}},DynamicPPL.VarInfo{NamedTuple{(:s, :w),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:s,Tuple{}},Int64},Array{Bernoulli{Float64},1},Array{DynamicPPL.VarName{:s,Tuple{}},1},BitArray{1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:w,Tuple{}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:w,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64},DynamicPPL.Model{var"###evaluator#1034",(),Tuple{},(),DynamicPPL.ModelGen{var"###generator#1035",(),(),Tuple{}}}}}, ::Turing.Core.ResampleWithESSThreshold{typeof(Turing.Inference.resample_systematic),Float64}) at C:\Users\Manoj\.julia\packages\Turing\d4vqQ\src\core\container.jl:307
 [5] step!(::Random._GLOBAL_RNG, ::DynamicPPL.Model{var"###evaluator#1034",(),Tuple{},(),DynamicPPL.ModelGen{var"###generator#1035",(),(),Tuple{}}}, ::DynamicPPL.Sampler{PG{(),Turing.Core.ResampleWithESSThreshold{typeof(Turing.Inference.resample_systematic),Float64}},Turing.Inference.PGState{DynamicPPL.VarInfo{NamedTuple{(:s, :w),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:s,Tuple{}},Int64},Array{Bernoulli{Float64},1},Array{DynamicPPL.VarName{:s,Tuple{}},1},BitArray{1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:w,Tuple{}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:w,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64},Float64}}, ::Int64, ::Nothing; kwargs::Base.Iterators.Pairs{Symbol,Int64,Tuple{Symbol},NamedTuple{(:iteration,),Tuple{Int64}}}) at C:\Users\Manoj\.julia\packages\Turing\d4vqQ\src\inference\AdvancedSMC.jl:264
 [6] #step!#8 at C:\Users\Manoj\.julia\packages\AbstractMCMC\iOkTf\src\interface.jl:87 [inlined]
 [7] macro expansion at C:\Users\Manoj\.julia\packages\AbstractMCMC\iOkTf\src\sample.jl:78 [inlined]
 [8] macro expansion at C:\Users\Manoj\.julia\packages\ProgressLogging\g8xnW\src\ProgressLogging.jl:328 [inlined]
 [9] (::AbstractMCMC.var"#18#21"{Bool,String,AbstractMCMC.var"#20#23",Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},Random._GLOBAL_RNG,DynamicPPL.Model{var"###evaluator#1034",(),Tuple{},(),DynamicPPL.ModelGen{var"###generator#1035",(),(),Tuple{}}},DynamicPPL.Sampler{PG{(),Turing.Core.ResampleWithESSThreshold{typeof(Turing.Inference.resample_systematic),Float64}},Turing.Inference.PGState{DynamicPPL.VarInfo{NamedTuple{(:s, :w),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:s,Tuple{}},Int64},Array{Bernoulli{Float64},1},Array{DynamicPPL.VarName{:s,Tuple{}},1},BitArray{1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:w,Tuple{}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:w,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64},Float64}},Int64})() at C:\Users\Manoj\.julia\packages\AbstractMCMC\iOkTf\src\logging.jl:11
 [10] with_logstate(::AbstractMCMC.var"#18#21"{Bool,String,AbstractMCMC.var"#20#23",Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},Random._GLOBAL_RNG,DynamicPPL.Model{var"###evaluator#1034",(),Tuple{},(),DynamicPPL.ModelGen{var"###generator#1035",(),(),Tuple{}}},DynamicPPL.Sampler{PG{(),Turing.Core.ResampleWithESSThreshold{typeof(Turing.Inference.resample_systematic),Float64}},Turing.Inference.PGState{DynamicPPL.VarInfo{NamedTuple{(:s, :w),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:s,Tuple{}},Int64},Array{Bernoulli{Float64},1},Array{DynamicPPL.VarName{:s,Tuple{}},1},BitArray{1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:w,Tuple{}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:w,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64},Float64}},Int64}, ::Base.CoreLogging.LogState) at .\logging.jl:398
 [11] with_logger(::Function, ::LoggingExtras.TeeLogger{Tuple{LoggingExtras.EarlyFilteredLogger{ConsoleProgressMonitor.ProgressLogger,AbstractMCMC.var"#1#3"{Module}},LoggingExtras.EarlyFilteredLogger{Base.CoreLogging.SimpleLogger,AbstractMCMC.var"#2#4"{Module}}}}) at .\logging.jl:505
 [12] with_progresslogger(::Function, ::Module, ::Base.CoreLogging.SimpleLogger) at C:\Users\Manoj\.julia\packages\AbstractMCMC\iOkTf\src\logging.jl:34
 [13] macro expansion at C:\Users\Manoj\.julia\packages\AbstractMCMC\iOkTf\src\logging.jl:10 [inlined]
 [14] mcmcsample(::Random._GLOBAL_RNG, ::DynamicPPL.Model{var"###evaluator#1034",(),Tuple{},(),DynamicPPL.ModelGen{var"###generator#1035",(),(),Tuple{}}}, ::DynamicPPL.Sampler{PG{(),Turing.Core.ResampleWithESSThreshold{typeof(Turing.Inference.resample_systematic),Float64}},Turing.Inference.PGState{DynamicPPL.VarInfo{NamedTuple{(:s, :w),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:s,Tuple{}},Int64},Array{Bernoulli{Float64},1},Array{DynamicPPL.VarName{:s,Tuple{}},1},BitArray{1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:w,Tuple{}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:w,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64},Float64}}, ::Int64; progress::Bool, progressname::String, callback::AbstractMCMC.var"#20#23", chain_type::Type{T} where T, kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at C:\Users\Manoj\.julia\packages\AbstractMCMC\iOkTf\src\sample.jl:76
 [15] sample(::Random._GLOBAL_RNG, ::DynamicPPL.Model{var"###evaluator#1034",(),Tuple{},(),DynamicPPL.ModelGen{var"###generator#1035",(),(),Tuple{}}}, ::DynamicPPL.Sampler{PG{(),Turing.Core.ResampleWithESSThreshold{typeof(Turing.Inference.resample_systematic),Float64}},Turing.Inference.PGState{DynamicPPL.VarInfo{NamedTuple{(:s, :w),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:s,Tuple{}},Int64},Array{Bernoulli{Float64},1},Array{DynamicPPL.VarName{:s,Tuple{}},1},BitArray{1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:w,Tuple{}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:w,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64},Float64}}, ::Int64; chain_type::Type{T} where T, resume_from::Nothing, progress::Bool, kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at C:\Users\Manoj\.julia\packages\Turing\d4vqQ\src\inference\Inference.jl:175
 [16] sample(::Random._GLOBAL_RNG, ::DynamicPPL.Model{var"###evaluator#1034",(),Tuple{},(),DynamicPPL.ModelGen{var"###generator#1035",(),(),Tuple{}}}, ::DynamicPPL.Sampler{PG{(),Turing.Core.ResampleWithESSThreshold{typeof(Turing.Inference.resample_systematic),Float64}},Turing.Inference.PGState{DynamicPPL.VarInfo{NamedTuple{(:s, :w),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:s,Tuple{}},Int64},Array{Bernoulli{Float64},1},Array{DynamicPPL.VarName{:s,Tuple{}},1},BitArray{1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:w,Tuple{}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:w,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64},Float64}}, ::Int64) at C:\Users\Manoj\.julia\packages\Turing\d4vqQ\src\inference\Inference.jl:174
 [17] sample(::Random._GLOBAL_RNG, ::DynamicPPL.Model{var"###evaluator#1034",(),Tuple{},(),DynamicPPL.ModelGen{var"###generator#1035",(),(),Tuple{}}}, ::PG{(),Turing.Core.ResampleWithESSThreshold{typeof(Turing.Inference.resample_systematic),Float64}}, ::Int64; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at C:\Users\Manoj\.julia\packages\Turing\d4vqQ\src\inference\Inference.jl:161
 [18] sample at C:\Users\Manoj\.julia\packages\Turing\d4vqQ\src\inference\Inference.jl:161 [inlined]
 [19] #sample#1 at C:\Users\Manoj\.julia\packages\Turing\d4vqQ\src\inference\Inference.jl:151 [inlined]
 [20] sample(::DynamicPPL.Model{var"###evaluator#1034",(),Tuple{},(),DynamicPPL.ModelGen{var"###generator#1035",(),(),Tuple{}}}, ::PG{(),Turing.Core.ResampleWithESSThreshold{typeof(Turing.Inference.resample_systematic),Float64}}, ::Int64) at C:\Users\Manoj\.julia\packages\Turing\d4vqQ\src\inference\Inference.jl:151
 [21] top-level scope at In[107]:11

I can see that this has something to do with the fact that different variables get defined in different control flows, and this is somehow upsetting something. This is toy code, I am looking at a case where I do want to use different local variables in different paths of a decision. How can I do that?

Not an expert but I believe you’re right. Maybe the sampler fails because it can’t find the v value on a sample immediately after it’s run a loop that goes through the w branch.

Have you tried declaring loose priors for both v and w before the branch so that they’re both present in every sample regardless of the conditional?