_ mistypes or refuses a few expressions
#68
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
_takes the type C gives an expression. A few expressions still come out with a type C would not give them, or with none:(+ a b)witha : (unsigned long)andb : (long long)is typedlong long. On LP64 hosts C makes itunsigned long long: a signed type of higher rank wins only when it can hold every value of the unsigned one.(+ d 1)withd : (enum color)staysenum color. C promotes an enum operand, and the sum is anint. (An enum constant is typed as its enum on purpose, so that its ops are found through it; arithmetic on one is another matter.)#(1 2.5)for[_ 2]is refused,type mismatch: expected: int got double, where the elements could join todoublethe way an operator's operands do.(var t [_ 8] "abc")is refused,type mismatch: expected: (¤ _ 8) got (* const char): a string literal is typed as the pointer it decays to, and achararray set from one is C's own idiom.In a block inside a function whose
xis along,(var x _ (+ x 1))is typed from the outerx. C's initializer reads the new one, uninitialized:That is a C pitfall more than a typing one, but
_makes it easy to write. Sex could refuse an initializer that names the variable it declares.(var q (const * _) (& k))withk : intemits correct C,int * const q = &k;, but warnsqualifiers differ between (const * _) and (* int). The top-levelconstis the object's own, and setting it from a non-const pointer is fine.Found with sexc 35604ad, probing corner cases the test suite does not cover; the rest of what that turned up is fixed on
more-tests-and-corner-cases.