emscripten-core / emscripten-core/emscripten

Failed to parse metadata - Newline escaping

Open
#12,514 3 comments 0 reactions 0 assignees View on GitHub
wontfix
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.