3 ms·
> In fact I wonder whether they plan to cover type checking at all. The "legality rules" section doesn't seem to think it's worth mentioning that a call which d
by UncleEntity 4y ago
> In fact I wonder whether they plan to cover type checking at all. The "legality rules" section doesn't seem to think it's worth mentioning that a call which doesn't type-check isn't legal.
This might be part of the ‘argument operands’ spec and it is assumed that the function call is passed legal values.
I’ve read a few language specs and don’t remember any specifically mentioning the means with which the implementation is required to type check values — could be completely wrong and just don’t remember so take that as you will.
Is that even a hard requirement or just something nice the compiler does to make life easier? For example, C was designed to be taken straight “off the wire” and compiled in a single stage with only keeping a symbol table around for bookkeeping. Sure, you can type check as you go but do you really have to?
- pornel 4y agoC can be done in a single pass, but I think it still requires keeping track of all types, at very least because sizeof() can take an arbitrary expression and essentially query its type. Rust boldly assumes that the code of the program will fit in RAM, which allows it to have order-independent definitions and not need prototypes. Rust implementations must do type checking (including type inference), because there's type-based method dispatch. However, Rust doesn't depend on borrow checking! The mrustc compiler is able to completely ignore lifetimes and still produce correct executables — if the input program was actually valid.