Verify expanded rval type before putting variable

Add acceptance test. Close #5302