Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@polynomial_ring is broken for coefficient rings not in AbstractAlgebra. #1630

Closed
fingolfin opened this issue Feb 28, 2024 · 1 comment
Closed

Comments

@fingolfin
Copy link
Member

The following is with Julia 1.9.4 and 1.10.1 in case it makes a difference.

Observe:

julia> K = QQ
Rational field

julia> @polynomial_ring(K,["x", "y"])
ERROR: UndefVarError: `K` not defined
Stacktrace:
 [1] macro expansion
   @ ~/.julia/packages/AbstractAlgebra/KwfqS/src/misc/VarNames.jl:322 [inlined]
 [2] top-level scope
   @ REPL[49]:1

Reason gets clear here:

julia> @macroexpand(@polynomial_ring(K,["x", "y"]))
quote
    #= ~/.julia/packages/AbstractAlgebra/KwfqS/src/misc/VarNames.jl:322 =#
    (var"#41#X", (x, y)) = (AbstractAlgebra.polynomial_ring)(AbstractAlgebra.K, [:x, :y])
    #= ~/.julia/packages/AbstractAlgebra/KwfqS/src/misc/VarNames.jl:323 =#
    var"#41#X"
end

So it evaluates K inside module AbstractAlgebra, instead of the current scope. I actually did run into this for the @alias macro.

I believe the fix involved using QuoteNode. But it's not easy to understand the code with all

CC @mgkurtz

mgkurtz added a commit to mgkurtz/AbstractAlgebra.jl that referenced this issue Feb 29, 2024
@mgkurtz
Copy link
Contributor

mgkurtz commented Feb 29, 2024

As I see it, we need an esc to evaluate the arguments in the correct scope. I provided a quickfix in #1633. Though, for a proper fix the keyword arguments should be escaped as well. I will also need to write some tests before I introduce some new bugs then. If you need this to work right now, #1633 should do the trick.

mgkurtz added a commit to mgkurtz/AbstractAlgebra.jl that referenced this issue Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants