emscripten-core / emscripten-core/emscripten
Using single-line arrow functions can cause closure compiler to inject an extra `return` keyword`.
Open
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
It seems like adding braces here actual makes the final output smaller:
```
emscripten_console_log: (str) => { console.log(UTF8ToString(str)) }
```
Compared to:
```
emscripten_console_log: (str) => console.log(UTF8ToString(str))
```
It seems to happen when closure inlines `UTF8ToString` into `emscripten_console_log`. In the former case I supposed closure knows that the function returns undefined, but in the later case it adds an extra `return` keyword to return the result of the `console.log` call.
Maybe there is some way to teach closure that `console.log` always returns undefined so this is not needed?
Contributor guide
Assessment
This issue has not been assessed yet.