Hi, I'm new here and started playing around with the example rust-platform. I am getting a compiler error now. I know that I broke the platform by changing the rust-platform/main.roc
file. Is it expected that I get
An internal compiler expectation was broken.
This is definitely a compiler bug.
Please file an issue here: https://github.com/roc-lang/roc/issues/new/choose
in this case or should I actually report?
It's hard to answer your question without more context. Are you able to share the error message? It may already be a known issue.
Sure. I would give more details when filing an issue, but I can of course also do that here :) I forked and committed my changes: https://github.com/roc-lang/roc/compare/main...mx-ws:roc:main
Basically I just played with the requires of the platform, changed main to mai, then did not provide it and changed types. Here is the output of RUST_BACKTRACE=full roc rocLovesRust.roc
inside the platform-switching
directory:
mxw@MacBook-Pro platform-switching % RUST_BACKTRACE=full roc rocLovesRust.roc
An internal compiler expectation was broken.
This is definitely a compiler bug.
Please file an issue here: https://github.com/roc-lang/roc/issues/new/choose
thread 'main' panicked at crates/compiler/module/src/symbol.rs:153:13:
ident_string's IdentIds did not contain an entry for 1 in module 17
stack backtrace:
0: 0x104f4c54c - __mh_execute_header
1: 0x10439d4cc - __mh_execute_header
2: 0x104f48530 - __mh_execute_header
3: 0x104f4c344 - __mh_execute_header
4: 0x104f4da60 - __mh_execute_header
5: 0x104f4d75c - __mh_execute_header
6: 0x104f4e064 - __mh_execute_header
7: 0x104f4de40 - __mh_execute_header
8: 0x104f4c9e4 - __mh_execute_header
9: 0x104f4dbd4 - __mh_execute_header
10: 0x1066297dc - __ZN4llvm15SmallVectorBaseIyE8grow_podEPvmm
11: 0x104a8dde4 - __mh_execute_header
12: 0x104d914a4 - __mh_execute_header
13: 0x104d55914 - __mh_execute_header
14: 0x10459ea7c - __mh_execute_header
15: 0x10468f608 - __mh_execute_header
16: 0x1045573c0 - __mh_execute_header
17: 0x1045356c4 - __mh_execute_header
18: 0x1045356e8 - __mh_execute_header
19: 0x104f405e8 - __mh_execute_header
20: 0x10455a52c - __mh_execute_header
Ideally roc should give a nice error instead of crashing. Though this is a more advanced use case because you are doing platform development.
There's not a lot of documentation, so it's harder to get started developing platforms.
Just wondering what your objective is here?
If you change the type on mainForHost back to Str I think it should work for you
The host is still expecting a RocStr from roc. If you want to change that you will need to change the API in lib.rs
My long/midterm goal would be that I can compile code at runtime as some kind of service. Say I expect the User to give me a string that compiles as a roc program. I would want to define a type Html
and require the Users program to provide ahtml: Html
. Here I feel like I have to decide whether I want to deal with the Html
type in the platform I'm writing (I haven't looked into this) or if this is possible from roc. I hoped for the latter, so my naive idea would be that I still require html: Html
. But in order that my platform just has to deal with a String, I would write a function htmlToString: Html -> String
und have mainForHost: String
and mainForHost = htmlToString html
.
Yeah, you definitely should be able to do that
In your simple example with Bool
, you have
mainForHost : Bool
This is the wrong type. Should be Str
still.
That may be the root cause of the crash. Not fully sure though.
Brendan Hansknecht schrieb:
Yeah, you definitely should be able to do that
You are right, I just compiled with main: Bool
and mainToHost: Str
and it worked! I was sure I already tried that without success, but I must have just done a mistake there =)
I still filed the issue in case we don't want that compiler error. But very happy to know I will be able to do what I was hoping to =)
Last updated: Jul 05 2025 at 12:14 UTC