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

Omit trailing undefined in external function calls #6653

Merged
merged 3 commits into from
Feb 27, 2024

Conversation

zth
Copy link
Collaborator

@zth zth commented Feb 27, 2024

(supersedes #6652)

Fixes #6543

This omits trailing undefineds when applying external functions with optional arguments, when the optional argument itself is not provided (or is None). Only applies to external calls, because that's the only place where it could matter.

Some more background: ReScript v11 with uncurried mode allows us to write much more ergonomic external function bindings because we can have optional arguments where we don't need a trailing unit to apply the function itself. But, this comes with a potential problem. All arguments, whether they're actually supplied or not, would be printed as undefined in the resulting JS. External JS calls might care about the number of args sent into it, so someJsFn(1) and someJsFn(1, undefined) is not always treated the same. Several JS APIs can break if provided the wrong amount of arguments unless intended.

cc @cristianoc what do you think about this?

@zth zth mentioned this pull request Feb 27, 2024
@zth zth enabled auto-merge (squash) February 27, 2024 08:14
CHANGELOG.md Outdated Show resolved Hide resolved
@zth zth disabled auto-merge February 27, 2024 10:25
@zth zth merged commit 1f2d463 into 11.0_release Feb 27, 2024
14 checks passed
@zth zth deleted the omit-trailing-undefined-in-external-calls branch February 27, 2024 10:25
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