Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test and fix wrong error with string literal in comment #1754

Merged
merged 4 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ merlin NEXT_VERSION

+ merlin binary
- destruct: Removal of residual patterns (#1737, fixes #1560)
- Do not erase fields' names when destructing punned record fields (#1734,
- Do not erase fields' names when destructing punned record fields (#1734,
fixes #1661)
- Ignore SIGPIPE in the Merlin server process (#1746)
- Fix lexing of quoted strings in comments (#1754, fixes #1753)

merlin 4.14
===========
Expand Down
4 changes: 1 addition & 3 deletions src/ocaml/preprocess/lexer_raw.mll
Original file line number Diff line number Diff line change
Expand Up @@ -658,10 +658,8 @@ and comment state = parse
state.buffer <- buffer;
Buffer.add_char state.buffer '\"';
comment state lexbuf }
| "{" ('%' '%'? extattrident blank*)? lowercase* "|"
| "{" ('%' '%'? extattrident blank*)? (lowercase* as delim) "|"
{
let delim = Lexing.lexeme lexbuf in
let delim = String.sub delim ~pos:1 ~len:(String.length delim - 2) in
state.string_start_loc <- Location.curr lexbuf;
Buffer.add_string state.buffer (Lexing.lexeme lexbuf);
(catch (quoted_string delim state lexbuf) (fun e l -> match e with
Expand Down
91 changes: 91 additions & 0 deletions tests/test-dirs/errors/issue1753.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
should be accepted
$ $MERLIN single errors -filename main.ml <<'EOF' | \
> jq '.value[0]'
> (* {%ext|babar|} *)
> EOF
null

should fail
$ $MERLIN single errors -filename main.ml <<'EOF' | \
> jq '.value[0]'
> (* {%ext id|babar|} *)
> EOF
{
"start": {
"line": 1,
"col": 0
},
"end": {
"line": 1,
"col": 2
},
"type": "typer",
"sub": [
{
"start": {
"line": 1,
"col": 0
},
"end": {
"line": 1,
"col": 2
},
"message": "String literal begins here"
}
],
"valid": true,
"message": "This comment contains an unterminated string literal"
}

should accept
$ $MERLIN single errors -filename main.ml <<'EOF' | \
> jq '.value[0]'
> (* {%ext id|babar|id} *)
> EOF
null

should accept
$ $MERLIN single errors -filename main.ml <<'EOF' | \
> jq '.value[0]'
> (* {id|babar|id} *)
> EOF
null

should accept
$ $MERLIN single errors -filename main.ml <<'EOF' | \
> jq '.value[0]'
> (* {|babar|} *)
> EOF
null

should fail
$ $MERLIN single errors -filename main.ml <<'EOF' | \
> jq '.value[0]'
> (* {id|babar|} *)
> EOF
{
"start": {
"line": 1,
"col": 0
},
"end": {
"line": 1,
"col": 2
},
"type": "typer",
"sub": [
{
"start": {
"line": 1,
"col": 0
},
"end": {
"line": 1,
"col": 2
},
"message": "String literal begins here"
}
],
"valid": true,
"message": "This comment contains an unterminated string literal"
}
Loading