emit IR for assignment to the element of array
add codegen test cases for array
some code cleanups

- remove useless comment in ir_emitter.cpp
- rename type::has<>() to type::is_a<>()
- use early return
- reduce duplication
- cosmetic changes