Skip to content

comments break mel.raw output #763

@joprice

Description

@joprice

I'm unsure if this is expected, but comments in mel.raw expressions can cause parse errors at runtime. Code like the following:

[%mel.raw {|
// before
const a = 1;
// after
|}];

Generates the js:

((// before
const a = 1;
// after));

And a parse error like the following:

Unexpected token (27:0)

      25 |
      26 | ((// before
    > 27 | const a = 1;
         | ^
      28 | // after
      29 | const b = 1;));

This works fine with [%%mel.raw ...], since I assume it allows statements. Could this be caught earlier in the pipeline to avoid invalid generated code, or is this expected? If so, feel free to close and maybe this will help someone in the future who might be confused about the single and double percent sign for ocaml directives.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions