X Tutup
The Wayback Machine - https://web.archive.org/web/20201211144006/https://github.com/tc39/test262/issues/2915
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detached Array Buffer semantics, follow-ups. #2915

Open
rwaldron opened this issue Dec 8, 2020 · 2 comments
Open

Detached Array Buffer semantics, follow-ups. #2915

rwaldron opened this issue Dec 8, 2020 · 2 comments
Assignees

Comments

@rwaldron
Copy link
Contributor

@rwaldron rwaldron commented Dec 8, 2020

From @rkirsling

@syg brought up array.length = 0; as an analogous operation to buffer detachment, and I'm thinking that's probably the best way to view the intent here. Thus in the above examples, includes should return true and join should return ",", but we should restore the HasProperty checks for indexOf / lastIndexOf such that they return -1.

I'll make these updates during my 12/9 work day.

@rwaldron rwaldron self-assigned this Dec 8, 2020
@rwaldron
Copy link
Contributor Author

@rwaldron rwaldron commented Dec 9, 2020

@rkirsling I have a few questions, each of which assumes the following:

function detach(ab) {
  if (ArrayBuffer.transfer) {
    ArrayBuffer.transfer(ab);
  } else if (ArrayBuffer.detach) {
    ArrayBuffer.detach(ab);
  } else if (typeof detachArrayBuffer === "function") {
    detachArrayBuffer(ab);
  } else if (typeof transferArrayBuffer === "function") {
    transferArrayBuffer(ab)
  } else if (typeof Worker === "function") {
    try { 
      eval("%ArrayBufferDetach(ab)") 
    } catch (e) {
      try {
        var w = new Worker("", {type: "string"});
        w.postMessage(ab, [ab]);
        w.terminate();
      } catch (e) {
        var w = new Worker("", {type: "classic"});
        w.postMessage(ab, [ab]);
        w.terminate();
      }
    }
  } else {
    throw new TypeError("cannot detach array buffer");
  }
}

let u8 = new Uint8Array([0xFF, 0xFF, 0xFF, 0xFF]);
detach(u8.buffer);

let a = [0xFF, 0xFF, 0xFF, 0xFF];
a.length = 0;

includes should return true

a.includes(/* anything */) would return false, should u8.includes(/* anything */) be consistent?

join should return ","

Similarly, a.join() === ""—shouldn't u8.join() === ""?

@rwaldron
Copy link
Contributor Author

@rwaldron rwaldron commented Dec 9, 2020

I think I answered my own question—those expectations are when detachment occurs after ValidateTypedArray

rwaldron added a commit that referenced this issue Dec 9, 2020
rwaldron added a commit that referenced this issue Dec 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.
X Tutup