Soss.jl icon indicating copy to clipboard operation
Soss.jl copied to clipboard

Can't use M as variable name

Open marius311 opened this issue 4 years ago • 4 comments

Random thing I unearthed w/ Soss v0.20.9 and GeneralizedGenerated v0.3.3, not sure if it belongs here or there but I only know how to trigger it from here:

model = @model () begin
    M ~ Normal()
end
rand(model) # invalid let syntax

marius311 avatar May 05 '22 07:05 marius311

Sorry for the delay on this. I've just released a new version that works with the latest MeasureTheory, so I think we can address this in a minor release.

The problem comes from this:

@gg function _rand(M::Type{<:TypeLevel}, _m::Model, _args)
    body = type2model(_m) |> sourceRand() |> loadvals(_args, NamedTuple())
    @under_global from_type(_unwrap_type(M)) @q let M
        $body
    end
end

@thautwarm I don't understand what this let M without a binding is doing. I think it would be ok to change all M references to _M, but even better would be to gensym the name. Do you see a way for that to work? Or if not we can just use _M or some more complicated version.

cscherrer avatar May 25 '22 01:05 cscherrer

I just played with Soss and this example, it seems that JuliaVariables.jl gets broken in 1.7 Will investigate this tonight.

thautwarm avatar May 25 '22 02:05 thautwarm

Hope I can give some results tomorrow. Debugging GG functions is hard, and I should make it support viewing the generated code with InteractiveUtils.less.

thautwarm avatar May 25 '22 14:05 thautwarm

Sounds good. Thanks for digging into this!

cscherrer avatar May 25 '22 14:05 cscherrer