Hi,
I would like to know the current expectations I can have with expect
, or if I'm using it in a wrong way. My current observations are:
expect
scope.it should work inside functions too when you use roc dev file.roc
with a recent build of the compiler
assuming the expect
is reached from main
I just uploaded the latest nightlies (except for macos x86_64) so those should be good
I built today from the source, to be sure I tested with your nightlies @Anton but I get the same output
well yeah so regarding what is shown: your observations are roughly correct. We look at what values are captured by the expect. other top-level values are constants, so they are not considered to be captured. So maybe we should tweak that slightly
inline expects do work right? This is with latest main
main =
expect 1 == 2
"Roc <3 Zig!\n"
gives
> cargo run -- dev examples/platform-switching/rocLovesZig.roc
Finished dev [unoptimized + debuginfo] target(s) in 0.25s
Running `target/debug/roc dev examples/platform-switching/rocLovesZig.roc`
๐จ Rebuilding platform...
Roc <3 Zig!
runtime: 0.057ms
โโ EXPECT FAILED โโโโโโโโโโโโโโโโโ examples/platform-switching/rocLovesZig.roc โ
This expectation failed:
7โ expect 1 == 2
^^^^^^โ
Ok, there is something weird on my Mac, I did exactly the same and I don't get the EXPECT FAILED
:
$ cat examples/platform-switching/rocLovesZig.roc
app "rocLovesZig"
packages { pf: "zig-platform/main.roc" }
imports []
provides [main] to pf
main =
expect 1 == 2
"Roc <3 Zig!\n"
$ cargo run -- dev examples/platform-switching/rocLovesZig.roc
Finished dev [unoptimized + debuginfo] target(s) in 0.17s
Running `target/debug/roc dev examples/platform-switching/rocLovesZig.roc`
๐จ Rebuilding platform...
Roc <3 Zig!
runtime: 0.075ms
$
interesting! we'll have to debug that then. On linux it does work, so there must be some subtle difference again that makes it fail on mac
@Ayaz Hafiz it did work on mac at some point right?
maybe it's a good idea to strace
(does that work on mac?) the process to see what syscalls actually happen
fwiw I never got inline expects to work on the M1 I use
I see no execution at all as of e589dc88a3dfc2d5bc14aac1c7d319d716bece0a
app "rocLovesC"
packages { pf: "c-platform/main.roc" }
imports []
provides [main] to pf
main =
expect 1 == 2
"Roc <3 C!\n"
โฏ target/debug/roc dev examples/platform-switching/rocLovesC.roc
๐จ Rebuilding platform...
what syscalls do you need to trace? strace
isn't a thing on Mac, the two other options (dtruss and Instruments) have only ever hung and sigsegv'd for me over roc binaries
ah, ok
well, I'm assuming that the expect does fail, but the parent process just gets an empty buffer and hence prints nothing
we can check what bytes expect is seeing before doing the printing. I can take a look later if you'd like
I'll look at it with Richard too later today if you don't get to it before then
@Ayaz Hafiz we didn't get to this, so if you can do some troubleshooting that would be great
understood
Last updated: Jul 06 2025 at 12:14 UTC