Skip to content

Array.prototype.slice() returns this #5123

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 5 commits into from

Conversation

sandersn
Copy link
Member

@sandersn sandersn commented Oct 5, 2015

Fixes #4988

@msftclas
Copy link

msftclas commented Oct 5, 2015

Hi @sandersn, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!


It looks like you're a Microsoft contributor (Nathan Shively-Sanders). If you're full-time, we DON'T require a Contribution License Agreement. If you are a vendor, please DO sign the electronic Contribution License Agreement. It will take 2 minutes and there's no faxing! https://cla.microsoft.com.

TTYL, MSBOT;

@mhegazy
Copy link
Contributor

mhegazy commented Oct 5, 2015

👍

// Array.prototype.slice returns this with zero arguments, allowing tuple slicing
let t1: [number, number] = [1, 2];
let t2: [number, number] = t1.slice();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add these test as well

let t3:[number, number] = t1.slice(0);
let t3:[number, number] = t1.slice(0,1);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, although those are negative tests -- only slice() returns this.

These are negative test cases; `slice(begin,end)` doesn't return `this`
because `(begin,end)` specify a *different* tuple type, which the compiler
is not prepared to infer.
@mhegazy
Copy link
Contributor

mhegazy commented Oct 28, 2015

is this ready to go?

@sandersn
Copy link
Member Author

No, I think it's superceded by my upcoming tuple kind proposal. @DanielRosenwasser and @ahejlsberg pointed out some problems in the discussion on #4988 -- specifically, that this implies that additional properties are copied, which is not true with slice.

@mhegazy
Copy link
Contributor

mhegazy commented Oct 28, 2015

let's close it then.

@sandersn sandersn closed this Oct 28, 2015
@mhegazy mhegazy deleted the nullary-array-slice-returns-this branch October 28, 2015 21:41
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants