[Design] Make unary negation of unsigned integers an error?

Hi Chapel Community —

As part of shoring up numerical operators in preparation for Chapel 2.0, we've been discussing what to do about the unary negation operator when applied to an unsigned integer. E.g.,

config param w = 64;
var u: uint(w) = 1;
var x = -u;
writeln(x, ": ", x.type:string);  // what value and type should 'x' have?

Our current proposal is to make this an error since unsigned integers aren't closed on unary negation, and the error will avoid surprises while also permitting us to change the behavior later if we decide we were wrong. Meanwhile, a user who really wants to negate a uint(w) can cast it to an int(w2) with a width of their choosing, and then apply the negation.

If you'd like to support or comment on this proposal, or suggest an alternative proposal, please head over to Proposal: Unary negation on unsigned integers should give an error · Issue #20807 · chapel-lang/chapel · GitHub and give it a thumbs-up or add a comment. Please note that we are hoping to wrap this question up in the next week or two if at all possible.