Skip to content

Commit 89b8108

Browse files
committed
Restore previous behavior of (x) = 1:y (equivalent to x = y again)
1 parent fffd641 commit 89b8108

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

M2/Macaulay2/d/evaluate.d

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,15 +1194,20 @@ globalAssignmentFun(x:globalAssignmentCode):Expr := (
11941194
globalAssignment(t.frameindex,t,newvalue));
11951195
11961196
ParallelAssignmentError(n:int):Expr := buildErrorPacket(
1197-
"parallel assignment: expected a sequence of " + tostring(n) + " values");
1197+
"parallel assignment: expected a sequence of " + tostring(n) + " value(s)");
11981198
ParallelAssignmentErrorAt(n:int):Expr := buildErrorPacket(
11991199
"parallel assignment: failure at argument " + tostring(n));
12001200
parallelAssignmentFun(x:parallelAssignmentCode):Expr := (
12011201
nlhs := length(x.lhs);
12021202
value := eval(x.rhs);
12031203
when value is Error do return value else nothing;
12041204
-- (x) = y should behave just like x = y
1205-
if nlhs == 1 then value = seq(value);
1205+
if nlhs == 1 then (
1206+
when value is a:Sequence do (
1207+
-- unless y is a sequence of length 1, then it behaves like x = y#0
1208+
if length(a) == 1 then nothing
1209+
else value = ParallelAssignmentError(1))
1210+
else value = seq(value));
12061211
when value
12071212
is values:Sequence do (
12081213
if nlhs == length(values) then (

M2/Macaulay2/tests/normal/parallel.m2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ assert Equation(z, 9)
105105
-- (x) = y should behave like x = y
106106
assert Equation((x) = 5, 5)
107107
assert Equation((x) += 2, 7)
108+
assert Equation((x) = 1:6, 6) -- except when the RHS is a sequence of length 1
108109

109110
-- 0-length LHS
110111
assert Equation(() = (), ())

0 commit comments

Comments
 (0)