Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0001281OCamlOCaml generalpublic2002-07-31 10:432002-07-31 13:04
Reporteradministrator 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionno change required 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0001281: Irrelevant warning
DescriptionFull_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

TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0002536)
administrator (administrator)
2002-07-31 10:58

> 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

(0002537)
administrator (administrator)
2002-07-31 13:04

This warning is sometimes annoying, but relevant :-)

- Issue History
Date Modified Username Field Change
2005-11-18 10:14 administrator New Issue


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker