Skip to content

Fix ArrayBufferView interface #1112

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

Closed
wants to merge 1 commit into from
Closed

Fix ArrayBufferView interface #1112

wants to merge 1 commit into from

Conversation

dcodeIO
Copy link
Member

@dcodeIO dcodeIO commented Feb 15, 2020

There has been a change a while ago that tried to unify the ArrayBufferView interface, but it turned out that the changes there are unsafe. In particular:

  • Array<T> must not expose .buffer since it can resize automatically, leading to use-after-free scenarios in the worst case.
  • Array<T> does not have a .byteLength property.

The only sensible solution there is to use distinct @unsafe fields for the ABV interface, with actual implementations providing safe getters.

Original breaking PR: #865
Related docs issue: https://github.com/AssemblyScript/docs/pull/7

@dcodeIO
Copy link
Member Author

dcodeIO commented Feb 15, 2020

Perhaps a better strategy would be to make Array<T> not extend ArrayBufferView anymore, just as in TS, so we can have proper members on ABVs.

@MaxGraey
Copy link
Member

Yeah agree, we discussed about this in the past btw

@dcodeIO dcodeIO closed this Feb 26, 2020
@dcodeIO dcodeIO deleted the fix-arraybufferview branch March 15, 2020 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants