Hi there! I was just dipping my toes back in for the first time in a while, trying out a combo of the roc mini tutorial and the roc syntax in one file. However, I seem to get a 'Secret does not implement unlock'. I've stripped it down to just the MRE:
app [main!] { pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.6/2BfGn4M9uWJNhDVeMghGeXNVDFijMfPsmmVeo6M4QjKX.tar.zst" }
import pf.Stdout
print! = |something| {
Stdout.line!(Str.inspect(something))
}
Secret :: {
key : Str
}.{
new : Str -> Secret
new = |k| { key: k }
say_hi = |_| {
"Hi!"
}
unlock : Secret, Str -> Str
unlock = |_secret, _password| {
"Whatever!"
}
}
main! = |_args| {
secret = Secret.new("my_secret_key")
print!(secret.say_hi())
# >> Roc crashed: Secret does not implement say_hi
print!(secret.unlock("open sesame"))
# >> Roc crashed: Secret does not implement unlock
Ok({})
}
I'm on an m2 mac, roc_nightly-macos_apple_silicon-2026-02-12-3bcd92c, roc version debug-3bcd92c5. Not sure if I'm missing something obvious with syntax :sweat_smile: but this was straight from the syntax file.
Ah I think I know what this is. It's a bug :ladybug:
If you move Secret into a type module Secret.roc I bet it would work properly... :sweat_smile:
Just a hunch
Yep, all good now
Just checking, is there any syntax/functionality etc for declaring modules or does roc just recursively discover and you can import at will?
This may help https://github.com/roc-lang/roc/blob/main/docs/langref/modules.md
A module == .roc file
You can group modules (files) using packages
So is it invalid to have types defined outside of a corresponding module?
I'm not sure about the question sorry... you define a type using := or :: syntax
Then you can use it anywhere in that same module, or in another module by import it
Ah I think I know what this is. It's a bug :ladybug:
I mean, is it the case that you can only define type X in a module/file called X.roc, and therefore the bug is that the error message should be more precise in telling me the cause of the error (there is no module with that type)?
Rather than I should be able to define that type in main.roc, and the bug you refer to that I can't :sweat_smile:
Oh, I think you should be able to do what you are, but the bug is that it's broken and doesn't let you
I suspect if you define a nominal type := or :: in the same module the static dispatch is broken
Ahh ok, got it, thanks
I can have a look soon and hopefully fix it. Just poking at another bug over my morning coffee :smiley:
I'm just trying to understand the implications of the module file naming - given that there are 4 types of module (type, platform, application, package) how would I go about defining some functions not necessarily associated with a type, e.g., some utils?
I'm having trouble reproducing the bug...
I had this same error earlier on x86 linux but I don't have access to that now
I go about defining some functions not necessarily associated with a type, e.g., some utils?
You could make a Utilities.roc like
Utilities :: {}.{
SomeType :: ...
some_func = ...
some_other_func = ...
}
Does that also define a unit type Utilities?
I'm on an m2 mac,
roc_nightly-macos_apple_silicon-2026-02-12-3bcd92c, roc versiondebug-3bcd92c5.
I'm also on an M2 mac... not sure how to reproduce
7:51:16 ~/Documents/GitHub/roc heads/main $ roc version
Roc compiler version debug-3bcd92c5
7:51:50 ~/Documents/GitHub/roc heads/main $ roc broken.roc
"Hi!"
"Whatever!"
This is the single file version? :thinking:
Ok, rather odd: if I run the whole syntax file (just copied from github with the platform set to yours) I get no error at all. But just running the MRE (removes everything not related to Secret) gives me the error
What's more is I was getting this error before but on the full file, and now only on the MRE. Is there some kind of cache I can clear?
You can use --no-cache flag with the cli
Still getting the error on MRE with --no-cache, and still _not_ getting the error on the full file :sweat_smile:
I don't particularly have the skills to debug this, sorry :sweat_smile:
So you're still getting the error with this code snippet?
I'm not sure what you mean by MRE and full file -- are there two different things you are running?
Sorry I was trying to make it clearer but it isn't. By MRE I meant my Minimum Reproducible Example (or not!) and the 'full' file is this and just changing the platform url
Thank you for clarifying
The process I went through was
linux x86 roc + 'full' syntax file -> Secret does not implement unlock
Then I had to leave that PC, so re-setup roc on my mac (clean start) and
m2 arm64 roc + 'full' syntax file -> Secret does not implement unlock
But now I've just tested the full file again on my mac and the error is gone :thinking:
oh wait... so the bug is happening on linux not mac?
I'm on an m2 mac,
roc_nightly-macos_apple_silicon-2026-02-12-3bcd92c, roc versiondebug-3bcd92c5.
I've only tried on my mac
That might be the issue... maybe we are doing something different on linux.
Jonathan said:
I had this same error earlier on x86 linux but I don't have access to that now
Sorry it's all a bit mixed up
Jonathan said:
The process I went through was
linux x86 roc + 'full' syntax file ->
Secret does not implement unlock
Then I had to leave that PC, so re-setup roc on my mac (clean start) andm2 arm64 roc + 'full' syntax file ->
Secret does not implement unlock- m2 arm64 roc +minimal file -> Same error again
But now I've just tested the full file again on my mac and the error is gone :thinking:
But this was the process
It may have been a stale cache from an older build of Roc
Looks like it - I just renamed the files and now I don't get any errors. (--no-cache wasn't helping however)
The last time I was trying roc was the rust compiler anyhow - would they overlap in the cache enough to cause this?
Yeah its a bit puzzling tbh -- there is no relation to the old rust compiler
I think we can lock this one in the memory bank and if it happens again we'll have another data point. Not sure how much more we can really get out of investigating this further now
I appreciate you taking the time to report it. It's the only way we will iron out all the issues
Yeh, not much can be done... :laughing: Thank you! Enjoy your coffee
https://github.com/roc-lang/roc/issues/9123
This is related issue. What's funny - I could reproduce that only if the file is main.roc xddd
Would you look at that... main.roc gives
20:58:38 ~/Documents/GitHub/roc heads/main $ roc version
Roc compiler version release-safe-3bcd92c5
20:59:01 ~/Documents/GitHub/roc heads/main $ roc main.roc
Roc crashed: Secret does not implement say_hi
Found the bug :tada:
What was the issue Luke?
The app and platform both have a module named main.roc
That's an overly simplified explanation... :sweat_smile:
I'm just putting a PR together, I'll link it here
Luke Boswell said:
That's an overly simplified explanation... :sweat_smile:
Sufficiently simple for me :laughing:
The simple "fix" for just main.roc was easy... but I'm taking my time to think about the right fix for the broader issue this uncovers.
We aren't properly handling module identifiers in a cross-package context.
Currently if you had two Color.roc modules in two different packages the module identifiers would collide and cause issues.
PR https://github.com/roc-lang/roc/pull/9178
Last updated: Feb 20 2026 at 12:27 UTC