2D Raycast Layer Mask not working

I’ve got the following code:

var layerMask : int = 1 << LayerMask.NameToLayer("Map");
var hit: RaycastHit2D = Physics2D.Raycast(castPt, -Vector2.up, layerMask);
if (hit != null) {
	print("collided with " + hit.collider.name + " on layer " + hit.collider.gameObject.layer);
}

This should make the ray ignore anything that isn’t on the layer “Map” (which is layer 10), correct? When I run I get the following log:

collided with Player on layer 8

why is this happening? Thanks

It looks like your are passing the layer mask in for the distance parameter. Here is the signature of the Physics2D.Raycast():

static RaycastHit2D Raycast(Vector2 origin, Vector2 direction, float distance = Mathf.Infinity, int layerMask = DefaultRaycastLayers, float minDepth = -Mathf.Infinity, float maxDepth = Mathf.Infinity);