diff --git a/src/misc/VarNames.jl b/src/misc/VarNames.jl index 6899d53085..089504ace4 100644 --- a/src/misc/VarNames.jl +++ b/src/misc/VarNames.jl @@ -290,8 +290,12 @@ function varnames_macro(f, args_count, opt_in) # Keyword arguments after `;` end up in `kv`. # Those without previous `;` get evaluated and end up in `kv2`. # Note: one could work around evaluating the latter if necessary. - kv = Meta.isexpr(first(args), :parameters) ? - popfirst!(args).args : Expr(:parameters) + if Meta.isexpr(first(args), :parameters) + kv = first(args) + args = args[2:end] + else + kv = Expr(:parameters) + end req(length(args) >= $args_count+1, "Not enough arguments") base_args = args[1:$args_count] diff --git a/test/generic/MPoly-test.jl b/test/generic/MPoly-test.jl index fe20bd6d7f..be1f486ef2 100644 --- a/test/generic/MPoly-test.jl +++ b/test/generic/MPoly-test.jl @@ -140,6 +140,17 @@ QQxxx3 = @polynomial_ring(QQ, :x=>1:3) @test QQxxx_ == (QQxxx3, [x1, x2, x3]) + # test support of kwargs + QQxxx4 = @polynomial_ring(QQ, "x#" => 1:3; internal_ordering=:lex) + @test QQxxx_ == (QQxxx4, [x1, x2, x3]) + + QQxxx_deglex_ = @inferred polynomial_ring(QQ, "x#" => 1:3; internal_ordering=:deglex) + @test internal_ordering(QQxxx_deglex_[1]) == :deglex + + QQxxx_deglex2 = @polynomial_ring(QQ, "x#" => 1:3; internal_ordering=:deglex) + @test internal_ordering(QQxxx_deglex2) == :deglex + @test QQxxx_deglex_ == (QQxxx_deglex2, [x1, x2, x3]) + ZZxy_ = @inferred polynomial_ring(ZZ, :x => (1:2, 1:2), :y => 0:3) ZZxy2_ = @inferred polynomial_ring(ZZ, :x => ["1, 1" "1, 2"; "2, 1" "2, 2"], :y => (0:3,))