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

Zed_utf8.singleton when I decode something with base64 package #270

Open
dinosaure opened this issue Jan 18, 2019 · 3 comments
Open

Zed_utf8.singleton when I decode something with base64 package #270

dinosaure opened this issue Jan 18, 2019 · 3 comments

Comments

@dinosaure
Copy link

──────────────────────────────────────────────────────────────────────────┬─────────────────────────────────────────────────────────────┬──────────────────────────────────────────────────────────────────────────
                                                                          │ Welcome to utop version 2.2.0 (using OCaml version 4.07.0)! │                                                                          
                                                                          └─────────────────────────────────────────────────────────────┘                                                                          
Findlib has been successfully loaded. Additional directives:
  #require "package";;      to load a package
  #list;;                   to list the available packages
  #camlp4o;;                to load camlp4 (standard syntax)
  #camlp4r;;                to load camlp4 (revised syntax)
  #predicates "p,q,...";;   to set these predicates
  Topfind.reset();;         to force that packages will be reloaded
  #thread;;                 to enable threads


Type #utop_help for help about using utop.

─( 12:25:11 )─< command 0 >─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────{ counter: 0 }─
utop # B64.decode ~pad:true "1US3OYAgsVtMvQf36C+oQ8TAI4C86qn2AGAxwjSI5TvF9IvhOqXD5KUHOZxTqyfrKwzc6bt3xSnG7zxWSax2HHxqxKCRU9zyIu1u5nx3zBHo8Giu5WDs5KZLwAXGVyUBxVz2lrW8WsVZXbSuaiDO5Q+6v5C1h1nfp1pS2NfCLu/GfdMOsad51BFSEorUszD7rrkJTt2YjScXk1LQI2zW+Bi+WdpoQdT6qNmmASqRd7FfEfcavuYmmtqTVgvtM1+Ui1AiEyvej53trIRJ/PN9AszEkepdLxumjAtW8/jDyUnNC7aJA/1cfbeWGxSTfkDa1h2kS7YugtDH5IJ/Yu4gZQ==";;
Fatal error: exception Invalid_argument("Zed_utf8.singleton")
➜  ocaml-base64 git:(master) ✗          

A dune utop on mirage/ocaml-base64#24 can reproduce this bug.

@pmetzger
Copy link
Member

@dinosaure I presume you expect this should work because it works in other contexts?

@dinosaure
Copy link
Author

Euh yes, a program like utop should not have a Fatal error and just give up. From what I know, this error appear when it tried to print the output string (B64.decode returns a (string, [ Msg of string ]) result, and in this case, an Ok ...).

The string is a random string (and surely an invalid UTF-8 string) but utop should, at least, continue the REPL (and did not try to print the output string).

@pmetzger
Copy link
Member

Ah, I didn't get that utop itself was exiting.

avsm added a commit to avsm/opam-repository that referenced this issue Jan 31, 2019
CHANGES:

The new feature in this release is to automatically install
printers marked with `[@@ocaml.toplevel_printer]` (ocaml-community/utop#269 @diml).
Adding this annotation to your libraries will remove the need
to have a separate `top` package to install the printers.

For example, in the [uri](https://github.com/mirage/ocaml-uri)
library, the old printing function for `Uri.t` was:

```
val pp_hum : Format.formatter -> t -> unit
```

Just adding this annotation results in `Uri.t` values being automatically
pretty printed in this version of utop.

```
val pp_hum : Format.formatter -> t -> unit [@@ocaml.toplevel_printer]
```

* Add cool screenshot to README (ocaml-community/utop#259 @rizo) and update links (ocaml-community/utop#257 @bobot)
* Improve robustness by using more tail-recursive functions (ocaml-community/utop#251 @gpetiot)
* Remove deprecation warnings in newer compilers (ocaml-community/utop#246 @ncihnegn)
* Minimum OCaml version supported is now 4.03.0 (ocaml-community/utop#254 @XVilka)
* Publish API documentation online and add `doc:` entry to opam file (ocaml-community/utop#270 @avsm)
* Port build to dune from jbuilder (ocaml-community/utop#268 @avsm)
* Upgrade local opam metadata to opam 2.0 format (ocaml-community/utop#268 @avsm)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants