Add shape checks when internalising fold functions.
Add shape checks when internalising fold functions.

ihc/futhark,HIPERFIT/futhark,ihc/futhark,ihc/futhark,diku-dk/futhark,diku-dk/futhark,CulpaBS/wbBach,diku-dk/futhark,mrakgr/futhark,mrakgr/futhark,mrakgr/futhark,HIPERFIT/futhark,HIPERFIT/futhark,diku-dk/futhark,diku-dk/futhark