Skip to content

Commit

Permalink
Fix handling of kwargs in @polynomial_ring
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Feb 28, 2024
1 parent 4546165 commit 97551de
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/misc/VarNames.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
3 changes: 3 additions & 0 deletions test/generic/MPoly-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@
QQxxx3 = @polynomial_ring(QQ, :x=>1:3)
@test QQxxx_ == (QQxxx3, [x1, x2, x3])

QQxxx4 = @polynomial_ring(QQ, :x=>1:3; internal_ordering=:lex)
@test QQxxx_ == (QQxxx4, [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,))
Expand Down

0 comments on commit 97551de

Please sign in to comment.