Fatal error: exception Invalid_argument("String.sub / Bytes.sub")
I have a reasonml/reason-react project that compiles ok with bs-platform 8.4.2.
First step is I want to upgrade compiler to rescript 9.1.4.
After updating dependencies I do a yarn rescript build and I got several fatal errors on different sources.
ex:
Fatal error: exception Invalid_argument("String.sub / Bytes.sub")
rescript: [434/645] src/grid/TextHeaderRenderer3.ast
this is the only message I got even with -verbose.
same error with -with-deps
this seems to be a parsing error, is that source code in reason or rescript syntax, is it available?
If it's a parser issue, I should be able to get more info about the error, it's location, etc. Is there a way to get that ?
Trying setting environment variable OCAMLRUNPARAM=b to see a stack trace.
it could be a bug, see similar issues: https://github.com/rescript-lang/syntax/pull/435
@cristianoc will try next week
This is what I get:
Fatal error: exception Invalid_argument("String.sub / Bytes.sub")
Raised at file "pervasives.ml", line 33, characters 20-45
Called from file "string.ml" (inlined), line 47, characters 2-23
Called from file "super_code_frame.ml", line 141, characters 4-93
Called from file "super_location.ml", line 67, characters 10-183
Called from file "format.ml", line 1276, characters 4-20
Called from file "format.ml", line 1286, characters 32-48
Called from file "format.ml", line 1286, characters 32-48
Called from file "format.ml", line 1276, characters 4-20
Called from file "format.ml", line 1276, characters 4-20
Called from file "format.ml", line 1276, characters 4-20
Called from file "format.ml", line 1337, characters 20-38
Called from file "list.ml", line 100, characters 12-15
Called from file "ast_iterator.ml", line 97, characters 4-28
Called from file "list.ml", line 100, characters 12-15
Called from file "ast_iterator.ml", line 505, characters 8-31
Called from file "list.ml", line 100, characters 12-15
Called from file "ppx_entry.ml", line 59, characters 6-65
Called from file "js_implementation.ml", line 219, characters 2-140
Called from file "rescript_compiler_main.ml", line 57, characters 5-258
Called from file "rescript_compiler_main.ml", line 496, characters 4-90
Re-raised at file "location.ml", line 311, characters 14-25
Re-raised at file "location.ml", line 311, characters 14-25
Re-raised at file "location.ml", line 311, characters 14-25
Re-raised at file "location.ml", line 311, characters 14-25
Re-raised at file "location.ml", line 311, characters 14-25
Re-raised at file "location.ml", line 311, characters 14-25
Called from file "location.ml" (inlined), line 316, characters 31-61
Called from file "rescript_compiler_main.ml", line 506, characters 6-37
the code is closed source and is a mix between reason/rescript.
Looks like something crashing when looking at lines around the error, in super-errors. ++ @chenglou
reproducible steps:
- checkout bs-css (master branch)
- yarn
- cd bs-css
- yarn re:build -> ok
- in
Css_Js_Core.reichangelet unsafe: (string, string) => rule;tolet unsafe: (. string, string) => rule;but dont change it in impl - yarn re:build -> exception
in general, error reporting should not trigger an exception, we will provide a fallback on this
can not reproduce on 9.1.4. This may be a windows specific issue, can you confirm with that?
On holidays, I'll test next week
@bobzhang it seems to be a Windows issue. I tested the repro case in Ubuntu with yarn, and I got a correct error reporting:
FAILED: src/Css_Js_Core.cmj
We've found a bug for you!
/home/dev/bs-css/bs-css/src/Css_Js_Core.re:1092:5-10
1090 │ );
1091 │
1092 │ let unsafe = (property, value) => D(property, value);
1093 │
1094 │ let userSelect = x =>
The implementation /home/dev/bs-css/bs-css/src/Css_Js_Core.re
does not match the interface src/Css_Js_Core.cmi:
Values do not match:
let unsafe: (string, string) => rule
is not included in
let unsafe: (. string, string) => rule
File "/home/dev/bs-css/bs-css/src/Css_Js_Core.rei", line 77, characters 1-95:
Expected declaration
File "/home/dev/bs-css/bs-css/src/Css_Js_Core.re", line 1092, characters 5-11:
Actual declaration
rescript: [31/36] src/Css_Legacy_Core.cmj
also, on Windows, same behavior with yarn or npm.
@giraud It seems super_errors are not robust to handle some invalid input, on Windows you can set BS_VSCODE=1 the env variable to bypass the super errors reporting as a work around.
I confirm I get a correct error output with that env var. is there a place where all these variables are explained ?
@giraud This is not supposed to be used. It is that super_errors are buggy, so I added it for a work around.
it seems interesting for ide integration 😄
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.