A proper typesystem for functional types will check at compile-time that in all places where you would assign such a function, the function will always have the right type.
So it's NOT a runtime error, it's a compile-time error, even though you can assign different functions at runtime.