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

FEAT: Support default arguments in functions #1481

Closed

Conversation

0xe
Copy link
Contributor

@0xe 0xe commented May 28, 2024

Adds support for default values in function parameters and default values in destructuring assignment.

What's not implemented yet, that I plan to implement subsequently:

  • Destructuring with defaults in for loops (eg: for (let {x = 2} = {}; ; ))
  • Reading [Symbol.iterator] from default array/object
  • Nested Literals

(Added ignored tests for these in DefaultParametersTest)

@rbri
Copy link
Collaborator

rbri commented May 28, 2024

@0xe wow great, i really need this feature and i will try to support you to get this out of the door.

@0xe 0xe force-pushed the scratch/satish/support-default-arguments branch 2 times, most recently from 6315a9e to 482d3d8 Compare May 28, 2024 14:00
@rbri
Copy link
Collaborator

rbri commented May 28, 2024

@0xe maybe you can start simple only by supporting scalar values

and i think we have to place this behind a feature switch e.g. like this
image

@0xe 0xe force-pushed the scratch/satish/support-default-arguments branch 3 times, most recently from 594defb to e22db83 Compare June 3, 2024 09:16
@0xe 0xe force-pushed the scratch/satish/support-default-arguments branch 6 times, most recently from a86b9b2 to 5ff61be Compare June 14, 2024 09:29
@rbri rbri marked this pull request as ready for review June 29, 2024 07:23
@rbri
Copy link
Collaborator

rbri commented Jun 29, 2024

because i like to work on this i removed the draft flag - hope this is ok

@rbri rbri marked this pull request as draft June 29, 2024 11:02
@rbri
Copy link
Collaborator

rbri commented Jun 29, 2024

draft flag is back

@0xe
Copy link
Contributor Author

0xe commented Jul 3, 2024

Sorry, haven't had the chance to get back at this due to some personal commitments. Should be able to work again on this from next week.

0xe and others added 7 commits July 10, 2024 17:05
- Fix arrow function parameters
- Gate to VERSION_200 language version
- Move tests to separate test class
     - Arguments object with default parameters
     - Function constructor
     - Array and Object destructuring
@0xe 0xe force-pushed the scratch/satish/support-default-arguments branch 2 times, most recently from 011f696 to d0b6032 Compare July 11, 2024 05:16
@0xe 0xe force-pushed the scratch/satish/support-default-arguments branch from d0b6032 to 28669b6 Compare July 11, 2024 05:42
@0xe 0xe force-pushed the scratch/satish/support-default-arguments branch from 97f9995 to 272d432 Compare September 6, 2024 19:33
@p-bakker
Copy link
Collaborator

Great to see your continued effort to implement this!

Think you're getting closer to this PR being ready for review and merge? Not trying to put pressure on or anything, just wondering

@0xe
Copy link
Contributor Author

0xe commented Sep 16, 2024

Great to see your continued effort to implement this!

Think you're getting closer to this PR being ready for review and merge? Not trying to put pressure on or anything, just wondering

Thank you! Yes, hopefully in a couple of days, I can mark it ready for review.

@0xe
Copy link
Contributor Author

0xe commented Sep 16, 2024

What's not implemented yet:

  • Destructuring with defaults in for loops (eg: for (let {x = 2} = {}; ; ))
  • Reading [Symbol.iterator] from default array/object
  • Nested Literals

(Added ignored tests for these in DefaultParametersTest)

@0xe 0xe marked this pull request as ready for review September 16, 2024 20:11
@0xe 0xe changed the title FEAT: Support default arguments in functions #WIP FEAT: Support default arguments in functions Sep 16, 2024
@gbrail
Copy link
Collaborator

gbrail commented Sep 17, 2024

This is looking good and a very helpful improvement judging from the number of tests that start to pass. Let us know when you have a chance for us to try it out more -- right now it needs another merge with master (sorry, things are actually moving sort of fast with this project!)

@0xe
Copy link
Contributor Author

0xe commented Sep 17, 2024

This is looking good and a very helpful improvement judging from the number of tests that start to pass. Let us know when you have a chance for us to try it out more -- right now it needs another merge with master (sorry, things are actually moving sort of fast with this project!)

Thank you. Updated with master.

@gbrail
Copy link
Collaborator

gbrail commented Sep 21, 2024

Thanks a ton for working on this! Right now we haven't been accepting merge commits in this codebase, which is why I'm trying to rebase it. I still think that's good code hygiene but it makes changes like this very difficult.

I tried to "git rebase" this branch myself, but I'm having to go through the entire long commit history and essentially try to understand what you tried to do each step of the way, and I quickly realized that I didn't know what you were doing. So, I have to apologize and tell you that I don't think I can merge this as it is.

I think that if we want to move this forward, then either:

  1. You can try to "git rebase master" this branch, and see if you can make it work.
  2. Or, if you recall what the major changes are, you can essentially apply them manually to the current source, either in a new branch and a new PR, or an update to this branch, so that GitHub can automatically apply these changes to master.

@0xe
Copy link
Contributor Author

0xe commented Sep 21, 2024

Thanks a ton for working on this! Right now we haven't been accepting merge commits in this codebase, which is why I'm trying to rebase it. I still think that's good code hygiene but it makes changes like this very difficult.

I tried to "git rebase" this branch myself, but I'm having to go through the entire long commit history and essentially try to understand what you tried to do each step of the way, and I quickly realized that I didn't know what you were doing. So, I have to apologize and tell you that I don't think I can merge this as it is.

I think that if we want to move this forward, then either:

  1. You can try to "git rebase master" this branch, and see if you can make it work.
  2. Or, if you recall what the major changes are, you can essentially apply them manually to the current source, either in a new branch and a new PR, or an update to this branch, so that GitHub can automatically apply these changes to master.

Understood. Let me try to rebase it against master.

@0xe
Copy link
Contributor Author

0xe commented Sep 21, 2024

@gbrail, I've created #1640, which contains the same changes as this but squashed and done on top of master. Closing this in favour of that PR.

@0xe 0xe closed this Sep 21, 2024
@0xe 0xe deleted the scratch/satish/support-default-arguments branch September 21, 2024 22:58
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.

Support ES2015 default parameter for functions
6 participants