File tree Expand file tree Collapse file tree 4 files changed +14
-0
lines changed
Expand file tree Collapse file tree 4 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -821,6 +821,7 @@ that it will always be returned by a call to the constructor when the same
821821base ring $R$ is supplied.
822822"""
823823function fraction_field (R:: Ring ; cached:: Bool = true )
824+ @req ! is_trivial (R) " Base ring must not be the zero ring."
824825 return Generic. fraction_field (R; cached= cached)
825826end
826827
Original file line number Diff line number Diff line change @@ -466,7 +466,9 @@ residue ring parent object is cached and returned for any subsequent calls
466466to the constructor with the same base ring $R$ and element $a$.
467467"""
468468function residue_field (R:: Ring , a:: RingElement ; cached:: Bool = true )
469+ @req ! is_trivial (R) " Base ring must not be the zero ring."
469470 iszero (a) && throw (DivideError ())
471+ @req ! is_unit (a) " Cannot create a field with one element"
470472 T = elem_type (R)
471473 S = EuclideanRingResidueField {T} (R (a), cached)
472474 return S, Generic. EuclideanRingResidueMap (R, S)
Original file line number Diff line number Diff line change 5151 @test ! (a in [b])
5252 @test a in keys (Dict (a => 1 ))
5353 @test ! (b in keys (Dict (a => 1 )))
54+
55+ # trivial rings can not be fields
56+ R = residue_ring (ZZ, 1 )[1 ]
57+ @test is_trivial (R)
58+ @test_throws ArgumentError fraction_field (R)
5459end
5560
5661@testset " Generic.FracFieldElem.printing" begin
Original file line number Diff line number Diff line change 6767
6868 @test x in keys (Dict (x => 1 ))
6969 @test ! (y in keys (Dict (x => 1 )))
70+
71+ # trivial rings can not be fields
72+ @test_throws ArgumentError residue_field (ZZ, 1 )
73+ R = residue_ring (ZZ, 1 )[1 ]
74+ @test is_trivial (R)
75+ @test_throws ArgumentError residue_field (R, R (2 ))
7076end
7177
7278@testset " EuclideanRingResidueFieldElem.printing" begin
You can’t perform that action at this time.
0 commit comments