Thanks for the answer. I’m not entirely sure how to do what you propose but using @macroexpand
seems to help me.
Currently the last line of @macroexpand
reads something like this:
JuMP.add_constraint(m, JuMP._build_my_constraint(JuMP.var"#_error#68"{Symbol}(Core.Box(Any[:m, :($(Expr(:(:=), :a, :({x + y <= 1}))))]), :constraint), a, JuMP.build_constraint(JuMP.var"#_error#68"{Symbol}(Core.Box(Any[:m, :($(Expr(:(:=), :a, :({x + y <= 1}))))]), :constraint), JuMP._functionize(var"#220###418"), MathOptInterface.LessThan{Float64}(0.0)), ..., "")
So the problem is the JuMP._build_my_constraint
it should be _build_my_constraint
as far as I understand.
I’m struggling with using esc
in a way that only the function name gets escaped and not the function arguments.
i.e I can produce:
JuMP.add_constraint(m, _build_my_constraint(JuMP.var"#_error#68"{Symbol}(Core.Box(Any[:m, :($(Expr(:(:=), :a, :({x + y <= 1}))))]), :constraint), $(Expr(:escape, :a)), build_constraint(JuMP.var"#_error#68"{Symbol}(Core.Box(Any[:m, :($(Expr(:(:=), :a, :({x + y <= 1}))))]), :constraint), _functionize(var"##510"), $(Expr(:escape, MathOptInterface.LessThan{Float64}(0.0)))), ..., "")
but there everything is escaped because I do escape everything
esc(:(_build_my_constraint($_error, $(esc(variable)), $rhs_buildcall, $S)))
I need to unescape the arguments now? If so how to do that?