Skip to content

Improve error for unexpected closing xml tag #12021

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

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
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: 3 additions & 0 deletions src/syntax/lexer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type error_msg =
| Invalid_escape of char * (string option)
| Invalid_option
| Unterminated_markup
| Unexpected_closing_markup_tag

exception Error of error_msg * pos

Expand All @@ -51,6 +52,7 @@ let error_msg = function
| Invalid_escape (c,Some msg) -> Printf.sprintf "Invalid escape sequence \\%s. %s" (Char.escaped c) msg
| Invalid_option -> "Invalid regular expression option"
| Unterminated_markup -> "Unterminated markup literal"
| Unexpected_closing_markup_tag -> "Unexpected closing markup tag"

type lexer_file = {
lfile : string;
Expand Down Expand Up @@ -717,6 +719,7 @@ let rec sharp_token lexbuf =

let lex_xml p lexbuf =
let name,pmin = match%sedlex lexbuf with
| '/' -> error Unexpected_closing_markup_tag p
| xml_name -> lexeme lexbuf,lexeme_start lexbuf
| _ -> invalid_char lexbuf
in
Expand Down
6 changes: 6 additions & 0 deletions tests/misc/projects/Issue12021/Main.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function main() {
<tag>
<tah> // typo
</tag>
</tag>
}
2 changes: 2 additions & 0 deletions tests/misc/projects/Issue12021/compile-fail.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--main Main
--interp
1 change: 1 addition & 0 deletions tests/misc/projects/Issue12021/compile-fail.hxml.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Main.hx:5: character 2 : Unexpected closing markup tag
Loading