`optimizer_with_attributes` failing when called inside a module

Hi folks,

I am having some problems getting some code to run inside a module. It runs fine when run directly in the REPL. Here is it:

    mod_name = Symbol("HiGHS")
    @eval using $mod_name
    mod = getproperty(@__MODULE__, mod_name)
    solver = optimizer_with_attributes(mod.Optimizer)

This runs as expected in the REPL, but inside a module I get:

ERROR: LoadError: The provided `optimizer_constructor` is invalid. It must be callable with zero arguments. For example, "Ipopt.Optimizer" or "() -> ECOS.Optimizer()". It should not be an instantiated optimizer like "Ipopt.Optimizer()" or "ECOS.Optimizer()". (Note the difference in parentheses!)

What are you trying to do? Messing with eval is usually discouraged

Thanks for the reply - turns out use of eval somewhere else was why my code wasn’t working thus providing a very nice example of why what you say is very true :slight_smile: