it drives me absolutely insane that this TypeScript compiles:
const num: number = [][0]
const num: number = [][0]
let number: i32 = [][0];
The compiler knows the array is 0-length, therefore the index is out of bounds, and emits this error: error: this operation will panic at runtime
--> src/main.rs:2:23
|
2 | let number: i32 = [][0];
| ^^^^^ index out of bounds: the length is 0 but the index is 0
|
= note: `#[deny(unconditional_panic)]` on by default
Of course, it's trivial to defeat by converting the array to a slice first, then you get a runtime error.As an aside, am I the only one who got Four Candles'd by that title?
const a = 'this is not a ' + typeof + 'number';
Or JSFuck[1] in that matter.[1]: http://jsfuck.com