string litteral with an extension node is wrongly marked as being unterminated
EmileTrotignon opened this issue · 3 comments
Thanks for the report @EmileTrotignon, I was able to reproduce the behavior you observe.
For reference, the manual says:
Furthermore, quoted strings {|...|} can be combined with extension nodes to embed foreign syntax fragments. Those fragments can be interpreted by a preprocessor and turned into OCaml code without requiring escaping quotes. A syntax shortcut is available for them:
{%%foo|...|} === [%%foo{|...|}] let x = {%foo|...|} === let x = [%foo{|...|}] let y = {%foo bar|...|bar} === let y = [%foo{bar|...|bar}]
For instance, you can use {%sql|...|} to represent arbitrary SQL statements – assuming you have a ppx-rewriter that recognizes the %sql extension.
It looks like Merlin lexer has diverged quite a bit from upstream for these cases.
Hi @voodoos
This syntax is not illegal, it is an extension node.
{%ext|abc|}
is a shortcut for
[%ext {|abc|} ]
I guess it must be documented in "language extension" : https://v2.ocaml.org/manual/extensionnodes.html#ss%3Abuiltin-extension-nodes
It should be rejected by the type checker as an uninterpreted extension if you do not have a ppx that handles it, but any parser should accept it.
Yes my bad, I was editing my comment but you were too fast :-)