I feel very strongly about this and need your support to get this applied:
I have created a patch such that /= behaves like the C /=.
After all, the +=, -= and *= already worked for both float and integer types, so why would division be an exception?
That means that depending on the result variable the division is either float or integer.
Explanation:
Previously, `a /= b` was unconditionally desugared to `a := a / b`.
Because Pascal's `/` always returns Double, this caused a compile-time
type error when `a` was any integer type, making `/=` unusable for the
most common case.
When the left-hand side of /= is an integer type , emit a divn (integer division) node instead of slashn.
This gives the same truncation-toward-zero semantics as Pascal's `div`
operator and C's `/=` on integers. Float LHS is completely unchanged.
No new syntax, keywords, or mode guards are introduced. All existing
compound-operator mechanics (single evaluation of LHS, constant folding,
range checks, division-by-zero checking) are inherited automatically
from the established div/slash code paths.
Since I am always at odds with git's patch mechanism, the patch is a bit longer than necessary, but only a few lines.
The patch is attached.
Follows some test code, I will add more:
program divtest;
{$coperators on}
var
a,b:integer;
c,d:double;
e,f:int64;
begin
a:=10;
b:= 3;
a /= b;
writeln(a);
c:= 3;
d:= 10;
//fail
//a /= c; // a is integer type
//writeln(a);
// pass
D /= b ; // d is float type
writeln(D);
a := -7;
b := 2;
a /= b;
writeln(a);
e := 1000*1000*1000;
f := 1000;
e /= f;
writeln(e);
c /= f;
writeln(c);
a /= f;
writeln(a);
// note that this never worked:
// writeln( a /= b);
end.
I hope for support to apply this, since it is my sincere opinion that this always was meant to work.
To me this has been a very important issue for years, and this provides a (the?) solution.
Please, test and humiliate me when it is wrong (it isn't).
Regards,
Thaddy
p.s.: patch is against trunk from 2026/3/31 9:23 UTC+1
Now zzzzzzzzzzzzzzzzzzzz I go and sleep.
In this case Claude was a big help solving the nitty gritty.