emscripten-core / emscripten-core/emscripten
Failed to parse metadata - Newline escaping
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
I'm trying to compile a block of code within an `EM_JS` macro. The offending piece is here, which does not link and fails to parse metadata.
`headers.trim().split(/[\r\n]+/);`
The problem is the `\` escape sequences, so, of course the next step is to escape the escapes.
`headers.trim().split(/[\\r\\n]+/);`
Linking succeeds, but the final javascript will contain an emitted actual newline character, like so.
```
headers.trim().split(/[\r\
]+/);
```
Which results in an exception being thrown for an invalid regex expression. Is there any workaround here? I did a little digging, and my best guess is that [this code](https://github.com/WebAssembly/binaryen/blob/master/src/wasm/wasm-emscripten.cpp#L193-L220) is finding the escaped newline and adding in one more escaped `\` character, which simply creates a real newline character in the output. Though I'm not sure about this.
Contributor guide
Assessment
This issue has not been assessed yet.