From 9a4a751d4004114a361dae1349acef5c1ed72f06 Mon Sep 17 00:00:00 2001 From: Tommy Hofmann Date: Thu, 12 Dec 2024 16:59:35 +0100 Subject: [PATCH] fix: check argument for map of polynomial rings (#4398) --- src/Rings/MPolyMap/MPolyQuo.jl | 1 + test/Rings/MPolyAnyMap/MPolyQuo.jl | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/src/Rings/MPolyMap/MPolyQuo.jl b/src/Rings/MPolyMap/MPolyQuo.jl index 0c1ebfc0ca54..9c4650858e86 100644 --- a/src/Rings/MPolyMap/MPolyQuo.jl +++ b/src/Rings/MPolyMap/MPolyQuo.jl @@ -152,6 +152,7 @@ end # The two main evaluation methods function (F::MPolyAnyMap{<: MPolyQuoRing})(g) if g isa elem_type(domain(F)) + @req parent(g) === domain(F) "Element not in domain" if coefficient_map(F) === nothing return _evaluate_plain(F, g) else diff --git a/test/Rings/MPolyAnyMap/MPolyQuo.jl b/test/Rings/MPolyAnyMap/MPolyQuo.jl index 6a7e3929552c..d8275e9afcb3 100644 --- a/test/Rings/MPolyAnyMap/MPolyQuo.jl +++ b/test/Rings/MPolyAnyMap/MPolyQuo.jl @@ -212,4 +212,14 @@ end # The test is whether the following two lines work at all AtoR = @inferred hom(A, R, QtoR, [ x^2, y^2, x*y ]) @test isone(AtoR(A(1))) + + let + Qt, (t,) = polynomial_ring(QQ, [:t]) + QT, (T,) = polynomial_ring(QQ, [:T]) + Q1, = quo(Qt, ideal(Qt, [t])) + Q2, = quo(QT, ideal(QT, [T^2])) + h = hom(Q2, Q1, [Qt(t)]) + @test_throws ArgumentError h(t) + end + end