It throws type error at run time, not compile time.
To be a statically type language you would need to throw the error at compile time.
How do you raise (or not raise) error of this code at compile time and still make it feel like dynamic type language?
x = (rand() > 0.5) ? 42 : "42"
y = x + 1;