endojs / endo

Endo is a distributed secure JavaScript sandbox, based on SES
Apache License 2.0
829 stars 72 forks source link

WIP fix(patterns,exo)!: args, splitArray, and splitRecord now default to … #1764

Closed erights closed 1 year ago

erights commented 1 year ago

Experiment re surprise that method guards with no declared rest by default accept extra args. This PR represents the most extreme and least compat "fix" to this surprise -- changing the semantics of splitArray and splitRecord so they also reject rest parts by default, i.e., if no rest argument is provided. Because of the way method guards delegate to splitArray, this takes care of the method guard "problem" as well.

Other options:

mhofman commented 1 year ago
  • Preserve the tolerant behavior, but not pass the values of the extra args through to the protected raw behavior method. This would preserve the input validation intent of method guards while still accommodating API growth and thus version slippage. (suggested by @turadg )

I'm in favor of this approach as it's the one I had initially suggested as the behavior I'd expect.

erights commented 1 year ago

Closing in favor of https://github.com/endojs/endo/pull/1765