Raycast2D layermask problem or edgeCollider ?

hey guys i 'm stuck like 1 hour trying to see what i am doing wrong… i am trying to raycast2d with layermask,so i am now realizing that raycast2d has somekind of problem with edgecollider because i have tried to mask by the inspector,i have tried with bitmask like 1 << 8 but again doesnt work…BUT there is a chance for me because i when i was debuging i found out that even with layermasks raycast detects a hit but how is that even possible? PLEASE HELP!
edit :
the script that is raycasting is attached to an object with collider and i disabled it because the raycast hits this collider even if i have a layermask filter and finaly it hited what i wanted,but here is the code :

RaycastHit2D hit = Physics2D.Raycast (transform.position, Vector2.up, 1 << LayerMask.NameToLayer ("field")); 

the field is 8th layer the gameobject that is raycasting has default layer,i tried the make the other one default too and it still detects it…

I’ve run into this before so I know what’s up. =p

Look closely at the third parameter on the documentation.

The third argument should be DISTANCE, but you are putting in a LAYERMASK.

If you want to raycast for an infinite distance, put float.PositiveInfinity as your third argument and move the Layermask to the forth argument.