You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 6958 Reporter: AltGr Status: closed (set by @xavierleroy on 2017-09-24T15:31:46Z) Resolution: fixed Priority: normal Severity: minor Fixed in version: 4.03.0+dev / +beta1 Category: standard library Tags: junior_job Monitored by:@hcarty
Bug description
I get:
Scanf.Scan_failure "scanf: bad input at char number 2: "end of input not found""
Steps to reproduce
run Scanf.unescaped """
The text was updated successfully, but these errors were encountered:
In fact, String.unescaped reverts an escaped string that follows the
OCaml lexing convention (as said by the documentation). It is
typically used to revert a call to String.escaped.
Here, the string """ (that contains only one char, a '"'), is an
invalid OCaml escaped string (and is, in particular, never returned by
String.escaped). It is refused by Scanf.unescaped as, for example, the
string "\x0g", since it does not follow the OCaml lexing convention.
May be you mean unescaping the string "\"" to obtain """.
However, the error message is not very clear, a small fix for that message may be useful...
Indeed. The thing is that Scanf.unescaped is more or less advertised as a general unescaping function, so it's tempting to use it just for interpreting \n, \t, \r, \000 and \x00 escapes, etc. ; in this regard, the limitation that it chokes on some (but not all) already unescaped characters is a bit surprising. Besides, there doesn't seem to be a good reason behind this limitation.
Since Scanf.unescaped is a parsing function, I don't find it surprising that it fails on bad inputs. If you wanted to make it total, you'd have to specify how to recover from syntax errors.
Original bug ID: 6958
Reporter: AltGr
Status: closed (set by @xavierleroy on 2017-09-24T15:31:46Z)
Resolution: fixed
Priority: normal
Severity: minor
Fixed in version: 4.03.0+dev / +beta1
Category: standard library
Tags: junior_job
Monitored by: @hcarty
Bug description
I get:
Scanf.Scan_failure "scanf: bad input at char number 2: "end of input not found""
Steps to reproduce
run Scanf.unescaped """
The text was updated successfully, but these errors were encountered: