Append record stub & union pattern match case

This PR contains the previous one (#480) and contains union pattern match case appending instead of prepending.

You may want to merge the previous PR before this one.
Is there any way to pass in expected range bounds in order to avoid this ugly check for out-of-bound ranges?