Runtime error: array index must be positive number, got: XX

This works

		viewNode = sme.GetView (sme.activeView)
		view = trackViewNodes[#sme][(viewNode.name)]
		if view.numsubs > 0 do (
			selNode = selView.getSelectedNodes()		--get selected node
			theMatsNMaps = for n = 1 to view.numsubs collect view[n].reference
 
			-- Working method
			theMats = for n = 1 to view.numsubs where (superClassOf view[n].reference == material) collect view[n].reference
 
			-- Runtime error: array index must be positive number, got: 02 - Default:Standard
			--theMats = for m in theMatsNMaps where (superClassOf theMatsNMaps[m] == material) collect m
		)

IF you unblock the part of the error I get:
Runtime error: array index must be positive number, got: 02 - Default:Standard

Can anyone explain why this is happening (i've never seen this error and google didn't help). Just for peace of mind.

Thanks.

I just want to collect the Materials in SME NOT maps.