{"action":"created","issue":{"url":"https://api.github.com/repos/tc39/ecmascript_simd/issues/308","labels_url":"https://api.github.com/repos/tc39/ecmascript_simd/issues/308/labels{/name}","comments_url":"https://api.github.com/repos/tc39/ecmascript_simd/issues/308/comments","events_url":"https://api.github.com/repos/tc39/ecmascript_simd/issues/308/events","html_url":"https://github.com/tc39/ecmascript_simd/issues/308","id":122380562,"number":308,"title":"Spec text doesn't throw on non-Number lane indices","user":{"login":"nmostafa","id":8812890,"avatar_url":"https://avatars.githubusercontent.com/u/8812890?v=3","gravatar_id":"","url":"https://api.github.com/users/nmostafa","html_url":"https://github.com/nmostafa","followers_url":"https://api.github.com/users/nmostafa/followers","following_url":"https://api.github.com/users/nmostafa/following{/other_user}","gists_url":"https://api.github.com/users/nmostafa/gists{/gist_id}","starred_url":"https://api.github.com/users/nmostafa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nmostafa/subscriptions","organizations_url":"https://api.github.com/users/nmostafa/orgs","repos_url":"https://api.github.com/users/nmostafa/repos","events_url":"https://api.github.com/users/nmostafa/events{/privacy}","received_events_url":"https://api.github.com/users/nmostafa/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-12-15T22:21:09Z","updated_at":"2015-12-15T22:54:22Z","closed_at":null,"body":"In #120, we agreed to accept only Numbers as lane indices.\r\n> 1.Throw an exception for the following cases:\r\n> Any lane index is a not a Number type.\r\n\r\nLooking at the spec text, I don't see this being enforced.\r\n\r\nThis is reflected in couple of places in the spec.\r\n\r\n1) SIMDToLane. It coerces any type to number. And only throws if out of range.\r\n```\r\nSIMDToLane( max, lane )#\r\n1.Let index be ToNumber(lane).\r\n2.ReturnIfAbrupt(index).\r\n3.If SameValueZero(index, ToLength(index)) is false or index < 0 or index ≥ max, throw a RangeError exception.\r\n4.Return index\r\n```\r\n\r\n2)  SIMDConstructor.shuffle( a, b, ...lanes ) and swizzle. Assumes 0 for missing lane indices. Missing lane indices are of Undefined value, and we should throw here. \r\n```\r\n3.For integer n from 0 to SIMDDescriptor.[[VectorLength]],a.Let lane be lanes[i], or 0 if lanes is not long enough.\r\n```\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/tc39/ecmascript_simd/issues/comments/164925416","html_url":"https://github.com/tc39/ecmascript_simd/issues/308#issuecomment-164925416","issue_url":"https://api.github.com/repos/tc39/ecmascript_simd/issues/308","id":164925416,"user":{"login":"ljharb","id":45469,"avatar_url":"https://avatars.githubusercontent.com/u/45469?v=3","gravatar_id":"","url":"https://api.github.com/users/ljharb","html_url":"https://github.com/ljharb","followers_url":"https://api.github.com/users/ljharb/followers","following_url":"https://api.github.com/users/ljharb/following{/other_user}","gists_url":"https://api.github.com/users/ljharb/gists{/gist_id}","starred_url":"https://api.github.com/users/ljharb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ljharb/subscriptions","organizations_url":"https://api.github.com/users/ljharb/orgs","repos_url":"https://api.github.com/users/ljharb/repos","events_url":"https://api.github.com/users/ljharb/events{/privacy}","received_events_url":"https://api.github.com/users/ljharb/received_events","type":"User","site_admin":false},"created_at":"2015-12-15T22:54:22Z","updated_at":"2015-12-15T22:54:22Z","body":"My understanding is that \"only accepting number literals as indices\" is an asm.js optimization requirement - there's no reason the functions can't or shouldn't accept numbers via a variable. It's very typical for builtin methods that take numbers to perform `ToNumber` on the item, and I think the SIMD methods should do that too - even though it wouldn't be necessary in the asm.js subset."}}