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

Irrelevant warning #3487

Closed
vicuna opened this issue Jul 31, 2002 · 2 comments
Closed

Irrelevant warning #3487

vicuna opened this issue Jul 31, 2002 · 2 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Jul 31, 2002

Original bug ID: 1281
Reporter: administrator
Status: closed
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: Michael Marchegay
Version: 3.05
OS: SunOs 5.7
Submission from: machine107.rd.francetelecom.com (193.49.124.107)

Hello,

When I compile my programs with the new ocaml-3.05, I have some irrelevant
Warning messages about "Illegal backslash escape in string". These messages are
issued on strings that are used for functions of the str library.

As these messages are just warning the programs operate correctly but the first
time I saw them, I found them obscure.

Example:
foo.ml:

let str = Str.replace_first (Str.regexp "name: ([A-Za-z]+)") "\1" "name:
Michael" in print_string str

ocamlc str.cma foo.ml

File "foo.ml", line 1, characters 47-49:
Warning: Illegal backslash escape in string
File "foo.ml", line 1, characters 58-60:
Warning: Illegal backslash escape in string
File "foo.ml", line 1, characters 64-66:
Warning: Illegal backslash escape in string

@vicuna
Copy link
Author

vicuna commented Jul 31, 2002

Comment author: administrator

When I compile my programs with the new ocaml-3.05, I have some
irrelevant Warning messages about "Illegal backslash escape in
string". These messages are issued on strings that are used for
functions of the str library.

There warnings are definitely relevant: the backslash character is an
escape character in a string, hence a \ in a string should be escaped
as \ :

let str = Str.replace_first (Str.regexp "name: ([A-Za-z]+)") "\1" ...

let str = Str.replace_first (Str.regexp "name: \([A-Za-z]+\)") "\1" ...

Since "(" isn't an escape sequence, the OCaml lexer will treat it as
a \ character followed by a ( character. However, you'll run into
troubles with e.g. "\n", which is one newline character instead of
followed by n. Hence the warning.

  • Xavier Leroy

@vicuna
Copy link
Author

vicuna commented Jul 31, 2002

Comment author: administrator

This warning is sometimes annoying, but relevant :-)

@vicuna vicuna closed this as completed Jul 31, 2002
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant