Skip to content

Commit 86b6f96

Browse files
committed
fix #3906, prevent promote(CC,RR)
1 parent da0a5fe commit 86b6f96

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

M2/Macaulay2/m2/engine.m2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ raw Number := x -> x_((class x).RawRing)
255255
raw InexactNumber := x -> x_((ring x).RawRing)
256256
Number _ RawRing := (n,R) -> rawFromNumber(R,n)
257257
RawRingElement _ RawRing := (x,R) -> rawPromote(R,x)
258+
raw Constant := raw @@ numeric
258259

259260
RawRingElement == RawRingElement := (x,y) -> x === y
260261

M2/Macaulay2/m2/matrix.m2

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ nottosamering := (X,Y) -> (
1212
else error("expected ",synonym X," and ",synonym Y," for compatible rings"))
1313
tosamering = (M,N) -> (
1414
R := ring M; S := ring N;
15-
if instance(R,InexactField) then R = ring R;
16-
if instance(S,InexactField) then S = ring S;
15+
R' := if instance(R,InexactField) ring R else R;
16+
S' := if instance(S,InexactField) then ring S else S;
1717
if R =!= S then (
18-
if isPromotable(R,S) then (promote(M,S),N)
19-
else if isPromotable(S,R) then (M,promote(N,R))
18+
if isPromotable(R',S) then (promote(M,S),N)
19+
else if isPromotable(S',R) then (M,promote(N,R))
2020
else nottosamering(class M,class N)
2121
)
2222
else (M,N))

M2/Macaulay2/m2/reals.m2

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ promote(RawRingElement,RRi') := (x,R) -> new RRi from x
103103
promote(RawRingElement,CC') := (x,R) -> new CC from x
104104
promote(RawRingElement,Number) := (x,R) -> new R from x
105105
promote(RawRingElement,RingElement) := (x,R) -> new R from x
106-
promote(Number,InexactNumber) := (x,RR) -> promote(x,default RR)
106+
promote(QQ,RR) :=
107+
promote(ZZ,RR) := (x,RR) -> promote(x,default RR)
108+
promote(Number,CC) := (x,CC) -> promote(x,default CC)
107109
promote(ZZ,RR') :=
108110
promote(QQ,RR') :=
109111
promote(RR,RR') := (i,K) -> toRR(K.precision,i)

0 commit comments

Comments
 (0)