Flow: Incorrect location with angry emoji 馃槨

Created on 22 Jun 2017  路  3Comments  路  Source: facebook/flow

Most helpful comment

Flow, in this case, is used as a parser for JavaScript and outputs an AST that is consumed by JavaScript. The expectations to me is that it adopts JavaScript's decision of what the length of strings is. Especially when every other parser (since they happened to be written in JavaScript) use UTF-16 lengths.

I understand that it's probably painful on your end to support this as flow is written in OCaml and UTF-16 support is probably uncommon.

All 3 comments

// 馃毀 TODO: Fix this bug please 馃槢

I'm not so sure if this is actually a bug in flow: the ranges flow give are correct if you interpret the file as UTF-8. Most likely both prettier and AST explorer use JavaScript to parse the code, and JavaScript uses UTF-16 to represent strings. An emoji in UTF-16 has a length of 2, while it has a length of 1 in UTF-8. So I don't think this is necessarily a bug in flow, but more so a disagreement on which character encoding to use when parsing JavaScript files.

Flow, in this case, is used as a parser for JavaScript and outputs an AST that is consumed by JavaScript. The expectations to me is that it adopts JavaScript's decision of what the length of strings is. Especially when every other parser (since they happened to be written in JavaScript) use UTF-16 lengths.

I understand that it's probably painful on your end to support this as flow is written in OCaml and UTF-16 support is probably uncommon.

Was this page helpful?
0 / 5 - 0 ratings