Omit trailing undefined in external function calls #6653
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
(supersedes #6652)
Fixes #6543
This omits trailing
undefineds
when applying external functions with optional arguments, when the optional argument itself is not provided (or isNone
). 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, sosomeJsFn(1)
andsomeJsFn(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?