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

Open
wants to merge 45 commits into
base: master
Choose a base branch
from

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 cb2858e to 1ba0bd5 Compare September 2, 2024 06:31
@0xe 0xe force-pushed the scratch/satish/support-default-arguments branch from 1ba0bd5 to a3ddc54 Compare September 4, 2024 18:30
@0xe 0xe force-pushed the scratch/satish/support-default-arguments branch from c7a7b76 to 97f9995 Compare September 6, 2024 19:29
@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.

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