Skip to content

Commit

Permalink
uncommented missing operator method errors
Browse files Browse the repository at this point in the history
e.g. A+B (where A and B are undefined symbols)
  • Loading branch information
mahrud committed Aug 22, 2024
1 parent 75be8db commit 6d2b431
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions M2/Macaulay2/m2/robust.m2
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ Thing.RobustPrintMethod = (msg, obj) -> toString stack { msg | ":",
horizontalJoin("\t", silentRobustNetWithClass(60, 5, 3, obj)) }

hush := false
commentGuardString := "--"
commentGuardNet := raise(horizontalJoin commentGuardString,-1)
commentGuardWidth := #commentGuardString
commentGuard := n -> if class n === String then concatenate(commentGuard,n) else (
(stack((height n + depth n):commentGuardNet))^(height n) | n
)
scan(flexibleBinaryOperators, op -> (
opstring := toString op;
ht := 8;
Expand All @@ -83,13 +77,13 @@ scan(flexibleBinaryOperators, op -> (
);
if hush then error(line1, " not displayed");
wid := max(printWidth,80); -- error might occur while printWidth is narrowed
wid = wid - commentGuardWidth - width preX;
wid = wid - width preX;
hush = true; -- prevent error message recursion
line2 := preX | silentRobustNetWithClass(wid,ht,errorPrintingTimeLimit,x);
line3 := preY | silentRobustNetWithClass(wid,ht,errorPrintingTimeLimit,y);
-* line4 := preZ | silentRobustNetWithClass(wid,ht,errorPrintingTimeLimit,z); *-
hush = false;
error toString stack(line1,commentGuard line2,commentGuard line3 -*,commentGuard line4 *-))));
error toString stack(line1, line2, line3 -*, line4 *-))));
if not Thing#?(op,Thing,Thing) then (
undocumented' (op,Thing,Thing);
installMethod(op, Thing, Thing, (x,y) -> (
Expand All @@ -99,12 +93,12 @@ scan(flexibleBinaryOperators, op -> (
if hush then error(line1, " not displayed");
preY := centerString(#preX, opstring);
wid := max(printWidth,80); -- error might occur while printWidth is narrowed
wid = wid - commentGuardWidth - width preX;
wid = wid - width preX;
hush = true; -- prevent error message recursion
line2 := preX | silentRobustNetWithClass(wid,ht,errorPrintingTimeLimit,x);
line3 := preY | silentRobustNetWithClass(wid,ht,errorPrintingTimeLimit,y);
hush = false;
error toString stack(line1,commentGuard line2,commentGuard line3))))));
error toString stack(line1, line2, line3))))));
scan( {(flexiblePrefixOperators,"prefix"), (flexiblePostfixOperators,"postfix")}, (ops,type) ->
scan(ops, op -> (
ht := 8;
Expand All @@ -117,23 +111,23 @@ scan( {(flexiblePrefixOperators,"prefix"), (flexiblePostfixOperators,"postfix")}
line1 := concatenate("no method for assignment to ", concatenate(type," operator ",op), " applied to objects:");
if hush then error(line1, " not displayed");
wid := max(printWidth,80); -- error might occur while printWidth is narrowed
wid = wid - commentGuardWidth - width preX;
wid = wid - width preX;
hush = true; -- prevent error message recursion
line2 := preY | silentRobustNetWithClass(wid,ht,errorPrintingTimeLimit,y);
-* line3 := preZ | silentRobustNetWithClass(wid,ht,errorPrintingTimeLimit,z); *-
hush = false;
error toString stack(line1,commentGuard line2 -*,commentGuard line3 *- ))));
error toString stack(line1, line2 -*, line3 *- ))));
if not Thing#?op and op =!= symbol ?? then (
undocumented' (op, Thing);
installMethod(op, Thing, (x) -> (
line1 := concatenate("no method for ", concatenate(type," operator ",op), " applied to object:");
if hush then error(line1, " not displayed");
wid := max(printWidth,80); -- error might occur while printWidth is narrowed
wid = wid - commentGuardWidth - width preX;
wid = wid - width preX;
hush = true; -- prevent error message recursion
line2 := preX | silentRobustNetWithClass(wid,ht,errorPrintingTimeLimit,x);
hush = false;
error toString stack(line1,commentGuard line2)));
error toString stack(line1, line2)));
))))

Thing#{Standard,Print} = x -> (
Expand Down

0 comments on commit 6d2b431

Please sign in to comment.