Home My Page Projects Dose: library and tools
Summary Activity Tracker Lists SCM Files

[#21696] This expression has type bytes but an expression was expected of type string

Date:
2018-07-21 19:16
Priority:
3
State:
Open
Submitted by:
thomas k (maddoctor)
Assigned to:
Nobody (None)
Summary:
This expression has type bytes but an expression was expected of type string

Detailed description
ocamlbuild -j 10 -no-links -cflags -warn-error,FPSXY common/common.otarget
Finished, 0 targets (0 cached) in 00:00:00.
+ ocamlfind ocamlc -c -warn-error FPSXY -w -24 -ccopt -O9 -package extlib -package re.pcre -package cudf -pp cppo -pp 'cppo -V OCAML:4.07.0 -D '\''OCAMLGRAPHVERSION VERSION'\''' -I common -I doselibs -o common/criteria_lexer.cmo common/criteria_lexer.ml
File "common/criteria_lexer.mll", line 21, characters 28-45:
Error: This expression has type bytes but an expression was expected of type
string
Command exited with code 2.
Compilation unsuccessful after building 45 targets (44 cached) in 00:00:00.
Makefile:64: recipe for target '_build/doselibs/common.cma' failed
make: *** [_build/doselibs/common.cma] Error 10

ocaml 4.07.0
dose3 5.0.1
Message  ↓
Date: 2018-07-21 19:53
Sender: Roberto Di Cosmo

This is not technically a bug in dose, but a change in the OCaml standard library, started back in OCaml 4.02, that now has a clear separation between unmodifiable strings (the type string) and modifiable strings (now the type bytes). In recent OCaml compilers, this separation is now enforced, hence the type error you see.

The proper way out of this requires quite a bit of work:
- find the values of type "string" in dose that are actually modified in place (this is tedious, but easy, as the compiler just tells you with the error you just saw) and change their type into "bytes";
- in the process, you may need to add some conversion from bytes to string and vice-versa
- explore the compatibility module Bytes that allows to use the bytes type in pre 4.02 OCaml compilers (see https://github.com/gasche/bytes-compat), and modify the build instructions to make sure it is used when a compiler of version < 4.02 is used.

--
Roberto

No Changes Have Been Made to This Item